News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Post and PM Inline Attachments

Started by dougiefresh, July 26, 2014, 09:14:08 PM

Previous topic - Next topic

dougiefresh

#300
Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
Subs-InlineAttachments.php, Line 635
A little style problem, I think. Additionally, when you just add a margin and no float, the download link will stick left regardless. Maybe it will be better to style the surrounding div whenever a download link is around here?

$divfloat = (isset($context['ila_params']['float']) ? ($context['ila_params']['float'] == 'center' ? ' style="margin-left: auto; margin-right: auto; display: block; "' : ' style="float: ' . $context['ila_params']['float'] . ';' . (!empty($context['ila_params']['margin']) ? ' style="margin:' . $context['ila_params']['margin'] . 'px' : '') . '"') : '');

New?
$divfloat = (isset($context['ila_params']['float']) ? ($context['ila_params']['float'] == 'center' ? ' style="margin-left: auto; margin-right: auto; display: block;"' : ' style="float: ' . $context['ila_params']['float'] . ';' . (!empty($context['ila_params']['margin']) ? ' margin: ' . $context['ila_params']['margin'] . 'px;' : '') . '"') : '');
:o  Wow!  I completely missed that!  This is embarrassing....

Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
The width tag does not work anymore. In the HTML code it looks like  width="240"
Has this something to do with the new param order?
I don't think so, but I added some code to the ILA_Fix_Param_Order function in order to remove any occurrences of " " from the message.  I honestly don't know where it comes from...

EDIT: Altering the ILA_Fix_Param_Order function so that it doesn't use the "&" character fixed this particular problem....

Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
Can you explain what the new function ILA_Fix_Param_Order does?
It puts all the parameters in order, so that parser will parse the ILA tag properly.  Beforehand, the parser refused to parse this:
[attachment id=0 msg=28 width=600]
Altering the parameter order so that the parameters are in proper order allows the parser to perform as expected.

Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
The override for inline attachment works, but the normal attachments under the post are displayed as images as well. But why? As far as I understand the code this should not happen, because only when ILA mod grabs the attachment context it sets the override, right?
:o You see what I mean by other stuff affects the mod, just like how the mod functions affects the forum?  :-\  Let me look into this....

Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
I tried out our hypothetical scenario with the following result:

Test 1: Quoted msg with an ILA without a msg ID.
Quoted bbcode [attachment=1,msg12377] (v1 format, only if the previous attachment has no msg ID)
New ILA bbcode [attachment id=1 msg=new] between quote.
Works properly, but after I click "edit" I see [attachment id=1 msg=12392 msg=12377]
I mean, it works, but now we have both msg IDs. Looks strange.
Confirmed and fixed for next version.

Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
Test 2: Same procedure, but first save and then edit post with new ILA.
Problem does not occure. New ILA bbcode [attachment id=1 msg=12392]
Confirmed.

Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
Test 3: Quoted msg with ILA with a msg ID
Quoted bbcode [attachment id=1 msg=12386] (v2 format)
New ILA bbcode [attachment id=1 msg=new] between quote.
Does not work at all. After "edit" I see [attachment id=1 msg=12386] twice. The new ILA is only under the post as attachment.

Test 4: Same procedure, but first save and then edit post with new ILA.
New ILA bbcode [attachment id=1 msg=12396]
Does not work at all. After "edit" I see [attachment id=1 msg=12396] twice. The new ILA is only under the post as attachment.
Still looking into these....

dougiefresh

#301
Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
The override for inline attachment works, but the normal attachments under the post are displayed as images as well. But why? As far as I understand the code this should not happen, because only when ILA mod grabs the attachment context it sets the override, right?
:-[ Silly me...  The override was actually a code change that ignored that fact that the particular option was checked.  When the forum loaded the context, the code changes I made got the forum to load the other relevant information necessary to make the inline attachments work.  What I failed to change was the display template so that it doesn't display the attachment as a picture...  It's been fixed for the next version....

Quote from: CrescentEclipse on July 05, 2015, 06:47:08 AM
Test 3: Quoted msg with ILA with a msg ID
Quoted bbcode [attachment id=1 msg=12386] (v2 format)
New ILA bbcode [attachment id=1 msg=new] between quote.
Does not work at all. After "edit" I see [attachment id=1 msg=12386] twice. The new ILA is only under the post as attachment.

Test 4: Same procedure, but first save and then edit post with new ILA.
New ILA bbcode [attachment id=1 msg=12396]
Does not work at all. After "edit" I see [attachment id=1 msg=12396] twice. The new ILA is only under the post as attachment.
Problems confirmed.  Looking into a solution....

EDIT: Found the solution.  Turns out the fix parameter function didn't empty the array used for processing the parameters after processing each tag, so things got reused, even though the params were from other ILA bbcodes...   :o  It's been fixed for the next version....

dougiefresh

Uploaded v3.10 - July 5th, 2015
o Fixed issue where msg parameter was added twice to ILA tags in new posts.
o Fixed ILA_Fix_Param_Order so that extraneous " " weren't added to the created link.
o Fixed ILA_Fix_Param_Order so that it doesn't reuse parameters from another ILA tag.
o Altered msg parameter to accept "new" as an acceptable parameter input for preview purposes.

CrescentEclipse

Quote from: dougiefresh on July 05, 2015, 08:16:26 AM
EDIT: Altering the ILA_Fix_Param_Order function so that it doesn't use the "&" character fixed this particular problem....

I don't really understand what's going on there, but you will know what you are doing, hopefully ;D
I am not that experienced in PHP coding. I can read and understand the code, but writing is something else.

One question. Is there a reason why you used the v1 bbcode for quoted ILAs without ID?

Quote from: dougiefresh on July 05, 2015, 09:27:34 AM
:-[ Silly me...  The override was actually a code change that ignored that fact that the particular option was checked.  When the forum loaded the context, the code changes I made got the forum to load the other relevant information necessary to make the inline attachments work.  What I failed to change was the display template so that it doesn't display the attachment as a picture...  It's been fixed for the next version....

No problem, I know you can fix it ;)
But will the non ILA attachments show as pictures if the option "Display image attachments as pictures under post" is activated again? Theoretically, this should happen as long as the ILA mod options are really seperated from the standard attachment options, right?

dougiefresh

Quote from: CrescentEclipse on July 05, 2015, 10:02:52 AM
Quote from: dougiefresh on July 05, 2015, 08:16:26 AM
EDIT: Altering the ILA_Fix_Param_Order function so that it doesn't use the "&" character fixed this particular problem....
I don't really understand what's going on there, but you will know what you are doing, hopefully ;D
I am not that experienced in PHP coding. I can read and understand the code, but writing is something else.
Well, I changed the character used to split the tag string and the problem went away.  I'm not sure why, but I suspect that the parser had some play in that particular problem....

Quote from: CrescentEclipse on July 05, 2015, 10:02:52 AM
One question. Is there a reason why you used the v1 bbcode for quoted ILAs without ID?
The mod doesn't change which format that the bbcode is originally in, so if the inline attachment was created using older versions of the mod, then it will be changed slightly to reflect the quoted message it came from....

Quote from: CrescentEclipse on July 05, 2015, 10:02:52 AM
Quote from: dougiefresh on July 05, 2015, 09:27:34 AM
:-[ Silly me...  The override was actually a code change that ignored that fact that the particular option was checked.  When the forum loaded the context, the code changes I made got the forum to load the other relevant information necessary to make the inline attachments work.  What I failed to change was the display template so that it doesn't display the attachment as a picture...  It's been fixed for the next version....
No problem, I know you can fix it ;)
But will the non ILA attachments show as pictures if the option "Display image attachments as pictures under post" is activated again?
Yes, the non-inline attachments should show as pictures underneath the post if the option is activated again.

Quote from: CrescentEclipse on July 05, 2015, 10:02:52 AM
Theoretically, this should happen as long as the ILA mod options are really seperated from the standard attachment options, right?
Theoretically, yes, it should happen....

In practice, it's a bit more complicated that a simple "yes" or "no".  Because the mod needs the image information from the context loading code, I have to make alterations in order to make sure I can get that information.  I also have to edit other places to make sure a clean install will function correctly.  If another mod comes along and further messes with the code, then all bets are off...  That being said, find me a reproducible situation like that and I'll try to fix my mod to accommodate that situation.

O:) Side question: Should the options to this mod be moved under Attachments and Avatars?  Looks to be a more natural fit than Modification Settings....

Niko_Bellic

Very nice mod. I like the ability to put my images where I want them in the posts.


As to your Side question: Should the options to this mod be moved under Attachments and Avatars?  Looks to be a more natural fit than Modification Settings....

I think that would be good. :)

CrescentEclipse

Quote from: dougiefresh on July 05, 2015, 11:26:48 AM
Quote from: CrescentEclipse on July 05, 2015, 10:02:52 AM
One question. Is there a reason why you used the v1 bbcode for quoted ILAs without ID?
The mod doesn't change which format that the bbcode is originally in, so if the inline attachment was created using older versions of the mod, then it will be changed slightly to reflect the quoted message it came from....

No and Yes. This was an ILA in the format [attachment=ID] without msg ID, from version 3.8 I think. When you quote such an ILA, then the mod adds the msg ID in v1 format, not v2 as expected. But I have not tested the behavior of v3.10 yet. But this is not a drama at all, so don't worry.

I will review the changes of your new version and test it tomorrow. I will give some feedback asap.

Quote from: dougiefresh on July 05, 2015, 11:26:48 AM
O:) Side question: Should the options to this mod be moved under Attachments and Avatars?  Looks to be a more natural fit than Modification Settings....

From my side, a nice to have change, but I can live with the settings as they currently are ;)

dougiefresh

#307
Uploaded v3.11 - July 10th, 2015
o Added code to internally transform closed ILA tags ([attach]) into proper ILA tags.  Thanks, dcmouser!
o Moved settings from Modification Settings to the Attachments and Avatars section.
o Fixed an undefined variable error in PersonalMessage.php.
o Made some performance optimization changes.




@dcmouser:  Thank you for the idea, as well as the code to implement closed ILA tags!

@Everybody:  For everybody who doesn't know what "closed tags" are, they are simply "[attach]".  The attachment numbers are assigned sequentially (aka: 1, 2, 3, etc).  Note that the [attach] tag is processed first, then [attachment], then [attachmini], then [attachthumb], then [attachurl].

dougiefresh

It's been brought to my attention by CrescentEclipse that multiple changes made in version 3.9 have disappeared.  CrescentEclipse and I have been reviewing the code changes to see what has disappeared between v3.9 and v3.10 and I am going to reimplement those changes (again).  I apologize for any problems this has caused anybody, but I thought that I would let people know!

RSI

Quote from: Niko_Bellic on July 05, 2015, 01:01:42 PM
As to your Side question: Should the options to this mod be moved under Attachments and Avatars?  Looks to be a more natural fit than Modification Settings....

It's fine where it is. I think all MOD's should automatically get installed under Modification Settings. It's unfortunate the majority of most mods don't do that because they ALL really belong there. That's why there is a Modification Settings place in the first place. I don't know how many times I've installed a mod and then had to go through and figure out where in the heck the settings to it were. Big thumbs down...

dougiefresh

@Everybody: I am releasing a public beta of v3.12 for testing here in this thread....  No, I'm not done fiddling yet with the code, as I may have found a reliable way to play MP4s using the ILA tag....

Quote from: RSI on July 11, 2015, 01:30:47 PM
It's fine where it is. I think all MOD's should automatically get installed under Modification Settings. It's unfortunate the majority of most mods don't do that because they ALL really belong there. That's why there is a Modification Settings place in the first place. I don't know how many times I've installed a mod and then had to go through and figure out where in the heck the settings to it were. Big thumbs down...
While I understand your reasoning, I disagree that ALL mods belong under Modification Settings.  Frankly, and I could be wrong on this, I personally think that the SMF team disagrees as well (not that I've talked to them), because in SMF 2.1 Beta 1, they stuck hooks EVERYWHERE in the admin area!  They obviously are trying to make it easier to add stuff to other areas without modification.

All I'm trying to do is to stick the settings where they seem to be a "natural fit".  While they "fit" just fine in the Modification Settings area, they fit better under the Attachments and Avatars (although I still don't understand why they grouped those two together like that)....

dougiefresh

Uploaded v3.12 - July 12th, 2015
o Resurrected some changes from v3.9 that somehow disappeared in v3.10.
o Fixed the ILA settings page so that it correctly saves the settings.
o Fixed ILA_Fix_Param_Order so that it doesn't drop all the parameters.
o Minor change to make sure internal message ID variable is set.
o Fixed some invalid regular expressions to make sure they get the message ID.
o Fixed error-creating operation within PersonalMessage.php.

@Everybody: This is the same as the beta published in the last post....  The last mod was sufficiently screwed up enough that this morning I decided to publish the beta as final v3.12....

dougiefresh

Uploaded v3.13 - July 12th, 2015
o Added "margin-left", "margin-right", "margin-top" and "margin-bottom" ILA parameters.
o Rewrote code to apply float and margin parameters to all ILA tags used.
o Fixed a few undefined errors within Subs-InlineAttachments.php.
o Fixed issue when quoted ILA tags were disabled, normal ILA tags didn't work either.
o Fixed issue where download link/counter didn't line up with image when margin was used.

RSI

Quote from: dougiefresh on July 11, 2015, 02:50:32 PM
While I understand your reasoning, I disagree that ALL mods belong under Modification Settings.  Frankly, and I could be wrong on this, I personally think that the SMF team disagrees as well (not that I've talked to them), because in SMF 2.1 Beta 1, they stuck hooks EVERYWHERE in the admin area!  They obviously are trying to make it easier to add stuff to other areas without modification.

All I'm trying to do is to stick the settings where they seem to be a "natural fit".  While they "fit" just fine in the Modification Settings area, they fit better under the Attachments and Avatars (although I still don't understand why they grouped those two together like that)....

The problem is lack of consistency. Some mods you install have a redirect after install to where the settings are and then some don't. Sometimes on the modification download page when there is no redirect they have screen shots showing where the settings are and then sometimes they don't. With those mods you have to navigate around trying to figure out where in the heck they are. That's why the really belong under Modification Settings.

They should all really be installed under Modification Settings first with user ability to move them after, like a user customization feature.

Anyway, that's my two cents worth...


adamtwar

I've installed Post and PM Inline Attachments version 3.13 on my forum http://forum.fontlab.com/ and whenever I click on the Insert Attachment 0 (or 1 etc.) link next to the attachment, the following BBCode gets inserted:
[attachment id=0 msg=31601
instead of:
[attachment id=0 msg=31601]
So the closing bracket is missing, which has quite terrible consequences when the user just saves the changes.

CrescentEclipse

Hm, can't confirm this bug, works in my forum.
I tested new attachments, already uploaded attachments and quoted attachments. All closing brackets are present.

Can you post your settings and other mods you installed?
Maybe something else is the culprit?

dougiefresh

Uploaded v3.14 - July 13th, 2015
o Fixed the "attach bbcode same as attachment" option so that it works as expected.
o Fixed incorrectly closed tag with SCEditor.




@adamtwar:  The bug is confirmed and fixed for this version.  Thank you for reporting this!

@CrescentEclipse: The bug is present if you are running the SCeditor mod.  If you aren't, you wouldn't see it.


adamtwar

Thank you for your express fix of the issue! :) It's all working well now.

I have another question. Have a look at:
http://forum.fontlab.com/bitfonter/(2015-06-25)-bitfonter-3-0-1-2015-for-mac-os-x-available!/msg31493/#msg31493
You'll see that I have one inline attachment there, inserted using attachthumb. I set the mod not to remove the attachments from the bottom of the post because, as you will see, I have Highslide Viewer (but the same effect is with the FancyBox 4 SMF). In the bottom list, I have the thumbnail, and if I click on it, it opens in Highslide.

How can I get the same behavior with an inline attachment? Is there a special shortcode (like attachthumblink or something :) ).

Also, I'd like to suggest that you add an option that allows me to customize which shortcode gets inserted with the "Insert Attachment" link that appears in the bottom list of attachments. By default, it's attachment but it would be great if I could set in the admin options which one it should be — it could be any of those you offer (attachment, attachmini, attachthumb etc.). This way, I could set the default standardized behavior for my users who just want to click on a link and have the same simple behavior.

Best,
Adam

dougiefresh

Quote from: adamtwar on July 13, 2015, 08:29:55 AM
Thank you for your express fix of the issue! :) It's all working well now.
You're welcome!  Thank you for the feedback.

Quote from: adamtwar on July 13, 2015, 08:29:55 AM
I have another question. Have a look at:
http://forum.fontlab.com/bitfonter/(2015-06-25)-bitfonter-3-0-1-2015-for-mac-os-x-available!/msg31493/#msg31493
You'll see that I have one inline attachment there, inserted using attachthumb. I set the mod not to remove the attachments from the bottom of the post because, as you will see, I have Highslide Viewer (but the same effect is with the FancyBox 4 SMF). In the bottom list, I have the thumbnail, and if I click on it, it opens in Highslide.

How can I get the same behavior with an inline attachment? Is there a special shortcode (like attachthumblink or something :) ).
Use the "attach" tag, but make sure that the "attach bbcode same as attachment" option is unchecked and you should get the attachment thumbnail shown expandable to full size using Highslide.

Quote from: adamtwar on July 13, 2015, 08:29:55 AM
Also, I'd like to suggest that you add an option that allows me to customize which shortcode gets inserted with the "Insert Attachment" link that appears in the bottom list of attachments. By default, it's attachment but it would be great if I could set in the admin options which one it should be — it could be any of those you offer (attachment, attachmini, attachthumb etc.). This way, I could set the default standardized behavior for my users who just want to click on a link and have the same simple behavior.
I can do that.  The new option will show up in the ILA settings page.

adamtwar

It seems that Post and PM Inline Attachments has a bug concerning deleting of attachments:

1. I add two attachments to a post (id 0 and 1).
2. I insert them in-line using the attachment shortcodes and publish by post.
3. Then I go to "Modify" to make some changes in the post. I uncheck attachment 1 from the list, and I upload a new attachment. So that should become attachment id 1 after I save the post. But instead, after publishing the post, in the place of my post where I had my attachment id=1 shortcode, a "missing image" with the filename of the OLD attachment (that I had already deleted) appears.

So far, the only way I could work around is that I upload the new attachment 2nd time so it gets id 2 (so I have id 0, 1 and 2, and I actually only use 0 and 2). So it seems that your plugin does not "refresh" the filenames behind the attachments.

Here's an example situation like this. You'll see some extra attachments at the bottom of the post, which are the ones I'd like to get rid of, but I cannot :)
hxxp:forum.fontlab.com/b13/(2015-07-11)-the-forum-upgraded/ [nonactive]


Advertisement: