News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Post and PM Inline Attachments

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

Previous topic - Next topic

RSI

Doug,

I'm playing around with a test board now and if I find something I will let you know.

In the meantime if anyone is interested the query below will find and replace all instances of [attach=n] with [attachment=n] in all of your posts. I just did it to my board and eliminated the problem.


UPDATE `smf_messages`
SET `body` = replace(body, '[attach=', '[attachment=')

RSI

I figured out what is causing it and it's in the smf_settings table. A new entry gets created after playing around with the checkboxes in Modifcation Settings => ILA that is not there until you play with those boxes and it stays and "0" and never changes again no matter what you do.

The entry that gets created is below and if I manually change it to "1" the problem stops.

ila_attach_same_as_attachment  0

That line is not there until you play with the checkboxes. What I did just to make sure was uncheck all of them and hit save. Then I rechecked all of them and hit save. Then I unchecked all of them again and hit save. Then I selected all of the boxes I wanted and hit save one last time. After doing that the ila_attach_same_as_attachment entry gets created in the smf_settings table and it stays at "0" and it will never change again unless you manually go into your database and change it to "1"

When that new entry gets created and is at "0" the two errors below are created when you view a post with [attach=n] in it. Then changing that entry to "1" makes it stop and the attachments expand again when clicking on them.

URL: http://mydomain.com/~/index.php?topic=1.0
8: Undefined index: thumb_width
File: /home/me/public_html/~/Sources/Subs-InlineAttachments.php
Line: 555

URL: http://mydomain.com/~/index.php?topic=1.0
8: Undefined index: thumb_height
File: /home/me/public_html/~/Sources/Subs-InlineAttachments.php
Line: 556

I guess the real questions is what's creating the extra entry in the smf_settings table and why does it lock it to "0"? Fix that and the problem is gone 8)


debiwebi

Hi there,
I was using this plugin back in March on my fairly new forum, but had problems with some of the attachments being invisible and so disabled it.

Now that I have time to focus on this (I really want this mod to work on my forum) I spent some time playing around with it on my test forum. So far, so good, with the Curve default theme! I especially love the float capability. When I first started using the mod I had a couple of errors, but it seems to be fine now. It may have been before I turned on "make sure attachment is 1." I'll attach the errors just so you can see them.

When I was installing the mod, I got an error message for my custom theme (I'm using Sunset 2.0 with some style changes). Error message attached. As a result, the Insert and Clear attachment links show: inactive javascript:void(0); and of course the mod doesn't work.

What do I need to add to Sunset's Display.template.php to make this mod work? Is there anything else I need to know about?

Thanks, I appreciate it.
Some mornings it just isn't worth
chewing through the leather straps.
~Emo

Unlimited Own Posts Editing Time

dougiefresh

#223
The next version will have support for the Sunset theme.  However, if you want to do the edits manually,

Change this in your Themes\sunset-2-0-1-5\Display.template.php file:
// Show a special box for unpproved attachments...
to this:
// Show a special box for unapproved attachments...
and it'll install correctly in the Sunset theme. 

debiwebi

Hi dougiefresh. Oh boy. I uninstalled & deleted the mod, fixed Display.template.php, reinstalled. I didn't get any warnings during install. The first post I made to test the mod did something really weird. The Insert and Clear links are still disabled, so I just hit Post. It deleted my greeking text and put some little marks in there (see screen capture, this also happened earlier today). They are barely visible unless highlighted. I copied & pasted into a .txt & enlarged the font -- it's my greeking at 1 pt.

I tried another post and although Insert and Clear are disabled, clicking Post gave me a normal looking post with the standard attachment at the bottom.

No new errors in the log.

If you're interested you can take a look at my tests, and if you become a member I'll even make you Admin so you can dig around. The test topics are here: www.tejadadesigns.com/upgrade21test/index.php?topic=7  You can see how nicely the mod is working when posted using the Curve theme: http://www.tejadadesigns.com/upgrade21test/index.php?topic=6

I'm attaching the Display file so you can check my handiwork.  :)

Some mornings it just isn't worth
chewing through the leather straps.
~Emo

Unlimited Own Posts Editing Time

dougiefresh

Something very wrong is going on here....  I don't understand why this is happening with the code....  I'm going to investigate these bugs this week.

RSI

#226
Quote from: dougiefresh on May 18, 2015, 07:23:24 PM
Something very wrong is going on here....  I don't understand why this is happening with the code....  I'm going to investigate these bugs this week.

That guys bug is really odd. I've installed this mod many many times and have never seen what he is seeing. Wonder is he has the no-sniff option checked?

I dug into this a little more and the only bug I found is connected to the below. The bbcode checkbox for controlling ila_attach_same_as_attachment doesn't get created in the smf_settings table during install and when you play with the boxes to where if finally shows up the bbcode checkbox has no control over it.

InlineAttachments.english.php

Find:
$txt['ila_attach_same_as_attachment'] = '<strong>attach</strong> bbcode same as <strong>attachment</strong>?';

That will never work, cannot have dual <strong></strong> tags in there. Not really needed anyway.

Replace:
$txt['ila_attach_same_as_attachment'] = 'Attach bbcode same as attachment?';

You probably need to also separate out the bbcode code and the width and height scaling code entirely within the Subs-InlineAttachments.php file.

Anyway, hope this helps...

RSI

Quote from: RSI on May 18, 2015, 10:51:24 PM
Quote from: dougiefresh on May 18, 2015, 07:23:24 PM
Something very wrong is going on here....  I don't understand why this is happening with the code....  I'm going to investigate these bugs this week.

That guys bug is really odd. I've installed this mod many many times and have never seen what he is seeing. Wonder is he has the no-sniff option checked?

I dug into this a little more and the only bug I found is connected to the below. The bbcode checkbox for controlling ila_attach_same_as_attachment doesn't get created in the smf_settings table during install and when you play with the boxes to where if finally shows up the bbcode checkbox has no control over it. The fix is below.

InlineAttachments.english.php

Find:
$txt['ila_attach_same_as_attachment'] = '<strong>attach</strong> bbcode same as <strong>attachment</strong>?';

That will never work, cannot have dual <strong></strong> tags in there. Not really needed anyway.

Replace:
$txt['ila_attach_same_as_attachment'] = 'Attach bbcode same as attachment?';

You probably need to also separate out the bbcode code and the width and height scaling code entirely within the Subs-InlineAttachments.php file.

Anyway, hope this helps...

RSI

P.S. You might also want to remove the <strong></strong> tags around the 1 in "Should first attachment should be numbered 1? That might possibly be causing a problem with certain browsers preventing that setting from working as well, but the dual tags in the other line were definitely preventing that one from working and that's all it was. It was actually that simple.

Anyway, I removed all of those tags in InlineAttachments.english.php within the v3.5 install package and reinstalled it again on my test board and the settings and everything work now. The problem is gone...

debiwebi

Quote from: RSI on May 18, 2015, 10:51:24 PM
That guys bug is really odd. I've installed this mod many many times and have never seen what he is seeing. Wonder is he has the no-sniff option checked?

I don't even know what no-sniff is, but it is unchecked.

Quote from: RSI on May 18, 2015, 10:51:24 PM
Anyway, I removed all of those tags in InlineAttachments.english.php within the v3.5 install package and reinstalled it again on my test board and the settings and everything work now. The problem is gone...

I can do this, but the mod works with the default template. I'm thinking my problem is specific to Sunset.

Dougie: I didn't know if access to my server and db would be helpful. I've made a new board only accessible to Admins with that information. I'd made the test forum a while ago, for another purpose, so already had it set up for individual access.
Some mornings it just isn't worth
chewing through the leather straps.
~Emo

Unlimited Own Posts Editing Time

RSI

I'll let Doug take it from here, but the no-sniff option is to disable a restriction that prevents images from appearing when using IE, etc.

What I found are those <strong></strong> tags in the two lines in the InlineAttachments.english.php file are causing the check boxes not to work when checked. Basically it's preventing the actual settings in the database itself from changing from "0" to "1" when the boxes are checked. It's probably hit and miss and depends on what browser people are using, but it explains why some were having a problem like the problem I was having.

Anyway, good luck with it...

dougiefresh

@RSI:  I'm sorry I haven't been able to look into the issue lately, as other things have come up.  What you found is VERY interesting!  I would never have figured that those tags would have made that much difference in the settings pages.....  I'll incorporate these changes into the next mod version.  Once I get the html creation code straightened out, I'll release the next mod version.




@debiwebi: Okay, let's address each "complaint" one by one.   ::)

The first complaint is that the forum software is rendering your text at font size of 1 pixel.  Frankly, I'm puzzled as to what you expected the forum to do when that's exactly what you instructed it to do with [size=1px]....  It rendered the text at 1 pixel in height.  That's not a bug in the forum software OR my mod.  Hmmm.... You probably meant to use [size=1] instead....  ::)

The second complaint is that the "insert attachment" and "clear attachment" links are disabled.  I visited your forum and clicked on those links several times each, and they seem to work just fine for me each time.  Do you have Javascript enabled in your browser?  If not, that would make those links unresponsive when clicked.  Having a browser that doesn't support Javascript would produce the same result.  What browser are you running?  Did the "clear attachment" link work before you installed the mod?  I uninstalled the mod on your test forum and the "clear attachment" link still works for me....  :o

The third "complaint" (is that even the right word for this one?) is about the "nosniff" option.  If you read this topic, specifically starting here, you'll get some insight as to what that particular option is meant to do....  8)

I hope this helps with your problem.....  ;D

RSI

Quote from: dougiefresh on May 19, 2015, 07:15:16 PM
@RSI:  I'm sorry I haven't been able to look into the issue lately, as other things have come up.  What you found is VERY interesting!  I would never have figured that those tags would have made that much difference in the settings pages.....  I'll incorporate these changes into the next mod version.  Once I get the html creation code straightened out, I'll release the next mod version.

The tag around the "1" in other line I mentioned is probably ok, but the dual tags in the attach bbcode same as attachment line is definitely preventing the checkbox from changing the value in the database. It might be because it starts out with '<strong> and maybe if it had a letter before the tag like 'make <strong>attach... it would work, but I seem to remember something about where you couldn't use the same tag on the same line twice.

To be safe I would just remove the tags from both lines and not take any chances. I understand why you were wanting to make those words appear in bold on the page, but it created a Gotcha!

Anyway, have fun...

SethStudent

This is debiwebi.
Sorry for the delay, I was not getting email notifications of new posts so I changed my email address and am now locked out of my account because I can't get the verification notice (which I wasn't expecting). But that's a different topic.

Quote from: dougiefresh on May 19, 2015, 07:15:16 PM
@debiwebi: Okay, let's address each "complaint" one by one.   ::)
The first complaint is that the forum software is rendering your text at font size of 1 pixel.

The thing is that I never made any font adjustments (or any other formatting) to the text. All I did was put some text in the box, add an attachment and click post. It did that font thing twice, only after I installed the Inline Mod and only when using the Sunset template.

Quote from: dougiefresh on May 19, 2015, 07:15:16 PM
The second complaint is that the "insert attachment" and "clear attachment" links are disabled.  I visited your forum and clicked on those links several times each, and they seem to work just fine for me each time.  Do you have Javascript enabled in your browser?  If not, that would make those links unresponsive when clicked.  Having a browser that doesn't support Javascript would produce the same result.  What browser are you running?  Did the "clear attachment" link work before you installed the mod?  I uninstalled the mod on your test forum and the "clear attachment" link still works for me....  :o

Did you change your template over to Sunset before testing? Again, the Mod works fine when using the default Curve. The problem happens only when I use Sunset. I use several different browsers: Firefox, Chrome, Opera and Safari (all Mac). I'll do tests using all four of them, I think I'd only tested with Firefox and Opera. Javascript is always on.

Quote from: dougiefresh on May 19, 2015, 07:15:16 PM
The third "complaint" (is that even the right word for this one?) is about the "nosniff" option.

That wasn't an issue for me, just something someone else brought up and I said I didn't know what it does.

I'll do more testing and get back to you if any issues come up. Right now I want get back into my real SMF account...

SethStudent

Hi Dougie, it's debiwebi, I still can't log into my regular SMF account.

This morning I ran tests on your Mod using the Sunset theme on four different (Mac) browsers: Chrome, Opera, Safari, Firefox. It doesn't work for me in Opera 29, the other three work great. I get the same problem as before: the Insert Attachment link doesn't work. I manually added [attachment=0]. It deleted the text and added [/attachment][/font]. If I just click Post without Inserting, it makes the font 2 px. My third and final Opera test result is attached—even more formatting thrown in.

So... I just thought you'd like to know for the future. I think at this point I'll retire the Sunset theme and just stick with the default.

Something else I noticed: When Insert Attachment does work, it inserts attachment=0, but to add a margin and float, I have to change it to "attachment id=0." I don't recall reading that anywhere.

dougiefresh

My computer has been down for repairs/improvements, so I haven't been able to do much of anything lately.  Hopefully, within the next few days, it will be operational again.....  Once it is, I'll look into it again....

Rayvon

For the most part this seems to be working fine for me and I haven't seen anything not post yet - but I do have an odd occasional error showing up in my log files ..

I use UTF8 English as the only language file available to users.

The errors;
One of two:
8: Undefined index: ila_insert
File: /home/newsi908/public_html/forums/Themes/default/Post.template.php
Line: 482

two of two:
8: Undefined index: ila_insert
File: /home/newsi908/public_html/forums/Themes/default/Post.template.php
Line: 466


The two lines from default/Post.template.php are

Line 466
<input type="file" size="60" name="attachment[]" id="attachment1" class="input_file" /> (<a href="javascript:void(0);" onclick="insertAttachment(', ((empty($context['current_attachments']) ? 0 : count($context['current_attachments'])) + $modSettings['ila_one_based_numbering']), '); return false;">', $txt['ila_insert'] ,' ', ((empty($context['current_attachments']) ? 0 : count($context['current_attachments'])) + $modSettings['ila_one_based_numbering']),'</a>)  (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';

Line 482
setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> (<a href="javascript:void(0);" onclick="insertAttachment(\' + current_attachment + \'); return false;">', $txt['ila_insert'] ,' \' + current_attachment + \')</a> (<a href="javascript:void(0);" onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '</a>)\' + \'</dd><dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(' . $txt['more_attachments'] . ')<\' + \'/a><\' + \'/dd>\');

Rayvon

Quote from: rayvon on May 28, 2015, 09:03:09 PM
For the most part this seems to be working fine for me and I haven't seen anything not post yet - but I do have an odd occasional error showing up in my log files ..

I use UTF8 English as the only language file available to users.

The errors;
One of two:
8: Undefined index: ila_insert
File: /home/newsi908/public_html/forums/Themes/default/Post.template.php
Line: 482

two of two:
8: Undefined index: ila_insert
File: /home/newsi908/public_html/forums/Themes/default/Post.template.php
Line: 466


The two lines from default/Post.template.php are

Line 466
<input type="file" size="60" name="attachment[]" id="attachment1" class="input_file" /> (<a href="javascript:void(0);" onclick="insertAttachment(', ((empty($context['current_attachments']) ? 0 : count($context['current_attachments'])) + $modSettings['ila_one_based_numbering']), '); return false;">', $txt['ila_insert'] ,' ', ((empty($context['current_attachments']) ? 0 : count($context['current_attachments'])) + $modSettings['ila_one_based_numbering']),'</a>)  (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';

Line 482
setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> (<a href="javascript:void(0);" onclick="insertAttachment(\' + current_attachment + \'); return false;">', $txt['ila_insert'] ,' \' + current_attachment + \')</a> (<a href="javascript:void(0);" onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '</a>)\' + \'</dd><dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(' . $txt['more_attachments'] . ')<\' + \'/a><\' + \'/dd>\');

I toggled the eval option and have this showing instead:

8: Undefined index: ila_insert
File: /home/newsi908/public_html/forums/Themes/default/languages/Profile.english-utf8.php (main sub template - eval?)
Line: 482

8: Undefined index: ila_insert
File: /home/newsi908/public_html/forums/Themes/default/languages/Profile.english-utf8.php (main sub template - eval?)
Line: 466

dougiefresh

I'm sorry I haven't been able to get back to you lately, as I've been working somewhere around 100 hours in the last 10 days....  I'll look into the bug report(s) that you reported....

dougiefresh

Uploaded v3.6 - June 5th, 2015
o Fixed language loading issue within Sources/Post.php.

Advertisement: