Uploading an attachment immediately after selecting an attachment.

Started by User2, January 28, 2023, 06:39:48 AM

Previous topic - Next topic

User2

Hello. Now, when I create a topic or answer in a topic and I want to attach an attachment, then I need to do two steps: step 1: selecting an attachment, step 2: clicking on the Upload button.
Is it possible to make attachments be embedded in just one step: the user selects an attachment and it is immediately inserted into the post. Thus, the Upload button is not needed.

The problem is that even I am an administrator, I forget to click Upload, and immediately click Post. After that, a warning appears and the user needs to download the attachment.

Steve

The attachment function is being revamped for the next patch so I'm not sure I'd be making changes until that happens.

And don't ask when it will be out because you'll get the stock answer of 'when it's ready'. If you really must have it now, I'll defer to one of the coders.
DO NOT pm me for support!

Sir Osis of Liver

Try this.  Don't think there are any other changes, but don't remember.  Save the original file.  It's in /Themes/default/scripts.

As Steve mentioned, this function should be added in 2.1.4.  You may have to replace the original file before upgrading.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2

I like it better as it was in version 2.0. In version 2.1 it is very difficult for the average user. It would be nice if the administrator could choose the way to insert attachments in the Admin Panel: method 1 - as it was in version 2.0, method 2 - as it became in version 2.1.
I never need the attach tag and the Insert button. And for visitors to my forum, this is generally something very difficult.

I think that visitors to my forum will not be able to understand for a long time what this attach tag is and will probably still click the Insert button.

Sir Osis of Liver, your file is working, thanks, I'll try to use it.

Sir Osis of Liver

That may not be such a good idea.  Was thinking about it early this a.m. (don't sleep well), and occurred to me that file's from an earlier 2.1 version and it's been patched since then by subsequent upgrades.  Code in 2.1.3 file is different.  It'll work in 2.1.3, but might break something.  Looking into that.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2

Sir Osis of Liver, is it better not to use the file that you suggested using in post #2?

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Ok, here is the 2.1.3 file edited to do auto upload.  This is the edit -


// Show the upload and cancel all buttons only if there is something to cancel/upload.
if (myDropzone.getFilesWithStatus(Dropzone.ADDED).length == 1) {
$('div#attachment_upload').find('#attach_cancel_all, #attach_upload_all').css('display', 'inline-block');
}

filesLimit = (myDropzone.options.maxFileAmount - myDropzone.getAcceptedFiles().length);

if (file.accepted !== true || filesLimit > 0) {
(function(element){
setTimeout(function(){
element.find('.upload').click();
}, 1000);
})(_thisElement);
}

});


Should be good until 2.1.4 is released.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2

Sir Osis of Liver, thank you, I will use this file.
Sir Osis of Liver, is it possible to make it so that it is like in version 2.0, i.e. that there is no attach tag and Insert button? Or does this require very big changes? That is, so that the attachment name appears, and on the right there was only the Delete button.

User2

The Bulletin Board Code "attach" tag is disabled on my forum.
It would be convenient if the "attach" tag is disabled on the forum, so that during the insertion of the attachment, there are no items associated with the "attach" tag.

Sir Osis of Liver

Should be fairly simple to remove the insert button from post template.  Will have a look when I get a chance.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

index.css


#button, .insertBBC {
display: none;
}


Just add this at the end.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2


Sir Osis of Liver

In the theme directory.  If you're using Curve2 it's in /Themes/default/css.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2

Sir Osis of Liver, delete the field in which the tag [attach id=...]...[/attach] is possible? Or are these serious changes to be made?
So that only the file name and the Delete button remain.

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2

Sir Osis of Liver, if I use the code from post #15, do I need to use the code from post #11?
Should I add this code to the end of the file?

Sir Osis of Liver

#17
The first css class removes the insert button, second one removes the bbc input field and dims.  Add them both to end of index.css.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters


User2

Sir Osis of Liver, is it difficult to reduce the height of the attachment? There is enough height for the height of the text, in which the file name and file size.
I don't need a preview of the image files, so you can not show the contents of the image files, it's enough to show a paper clip or not show anything at all. It is better not to show anything at all, but you can use a simpler option.

Advertisement: