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.

Sir Osis of Liver

You can remove the thumbnail with this -


.attach-preview {
display: none;
}


But don't think it's a good idea.  Reducing the size of the thumb is giving me grief.  >:(


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

                                     - R. Waters

User2

Sir Osis of Liver, I have removed the preview, but the height is still large. Is it difficult to reduce the height of the attachment?
And is it still possible to remove the size of the attachment? I don't need to know what the size of the attachment is.

Sir Osis of Liver

You can reduce the height of .infobox to 85px, any more than that and delete button will be displayed below it.  Would require editing template to fix that, which is not a good idea.


.infobox {
color: #222;
background: #cfc;
border-top: 1px solid green;
border-bottom: 1px solid green;
height:  85px;
}


You're knocking yourself out to do something that will have to be redone when 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, is it still possible to remove the size of the attachment? I don't need to know what the size of the attachment is.

Quote from: Sir Osis of Liver on February 01, 2023, 08:14:58 PMWould require editing template to fix that, which is not a good idea.
Why is this a bad idea? Is this difficult to do or for some other reason?

Kindred

because it will probably break future upgrades... like the next one that modifies attachment behavior
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Sir Osis of Liver

So far you haven't made any changes that aren't easily reversed - one edit to smf_fileUpload.js, some classes added to index.css.  But if you start messing with templates you're more likely to run into problems with next upgrade.  The more changes you make, the more diffucult it will be to find and undo them.  Wait until 2.1.4 is released, see what the upgraded attachments feature looks like, then you can do some customizing.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2

Sir Osis of Liver, is it still possible to remove the size of the attachment? I don't need to know what the size of the attachment is.

Sir Osis of Liver

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

                                     - R. Waters

User2

Sir Osis of Liver, I also wanted to remove the progress bar. At first I couldn't figure out what it was at all: I was thinking what kind of text input field, because I thought it was just some kind of horizontal line. It was only when I uploaded a few files that I realized that this was a progress bar. I think it will also be a long mystery for visitors.

Sir Osis of Liver

You can remove it with this -


.progress_bar {
display: none !important;
}


But it's a bad idea for two reasons:

- If a member uploads a large file, it will look like nothing's happening until upload is completed (dead air).
- It may break things in other templates.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2

Sir Osis of Liver, is it possible to change the position of the Delete button in a simple way? As I understand it, now the Delete button is aligned to the lower right corner. Is it possible to make the button align to the right edge in the middle or to the upper right corner?

Kindred

dude, you are seriously trying to completely design a new theme, piece by piece, one line at a time.

I suggest that you start trying to learn how CSS works and use the inspector tool of your browser.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

User2

Sir Osis of Liver, hello, is it difficult to do what I asked in post #30?

Sir Osis of Liver

Quote from: Kindred on February 04, 2023, 01:25:10 PMI suggest that you start trying to learn how CSS works and use the inspector tool of your browser.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

User2

Sir Osis of Liver, this is my last question, I don't plan to make any more changes on my forum. Therefore, because of this question alone, I do not have such an opportunity to study CSS, because I do other things.
If this is a difficult question that could ruin the forum, then I don't need it. If this is a simple solution, like the others that you suggested in this topic, then you can apply.

Sir Osis of Liver

<sigh> We all do other things.

Not the best way to do it, but it works as a temporary solution -


.attach-ui .button {
margin: -45px 0 0 0;
}


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

                                     - R. Waters

User2

Sir Osis of Liver, when can problems occur with these changes? When the next patch is released?
I don't plan to make any more changes unless I plug in some mod in the future.

Now I accidentally saw (I use F12 and clicked Toggle device toolbar), if you change the position of the Delete button and the height of the attachment, then in Smartphone mode the elements are not where they should be.

Diego Andrés

1- Items could overlap but it might not be an issue...
2- No release date, when it's ready. You can track progress on GitHub.
3- Would need to add a css media query for that. I'm not following the topic much but hopefully Sir Osis can point you in the right direction.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Kindred

Or he could start learning some css rather than having people rewrite his whole theme one line at a time

And Yes,  any time you make a change,  you need to test on PC, tablet, and phone sized screens at thr very least
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

User2

Sir Osis of Liver, thank you for participating in this topic.
You have solved the main tasks, the remaining (height of the attachment) is insignificant.
On my forum, many attachments are not attached (up to five), so the height of the attachments will not create difficulties.

Advertisement: