News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Post and PM Inline Attachments

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

Previous topic - Next topic

RSI

#40
Hello,

I'm using SMF 2.0.7 and I installed your pervious version 2.1 a couple of weeks ago and I'm getting the error in the error log below.

I've had Highslide installed since last spring and when I place images inline with your mod the inline images work fine with Highslide.

I don't know why I'm getting the errors though? I saw it again yesterday and it said line 469. This time it's line 470.

It looks like its happening each time I insert an image inline. It generates the error even though the images are inline and Highslide works with them fine.

I want to correct this... How?  Is there a "Subject" line missing in the Modifications.english.php file or something?

mydomain.com/index.php?action=post2;start=25;board=8

8: Undefined index: subject

File: /home/me/public_html/Sources/Subs-InlineAttachments.php
Line: 470

RSI

Strange..., I took the latest Subs-InlineAttachments.php file from your v2.2 and overwrote the one I was using from v2.1 and it fixed the problem.

Looks like you added some to that file just recently ???

dougiefresh

Quote from: RSI on December 27, 2014, 04:23:28 PM
Strange..., I took the latest Subs-InlineAttachments.php file from your v2.2 and overwrote the one I was using from v2.1 and it fixed the problem.

Looks like you added some to that file just recently ???
Yeah, I fixed something about the mod and, off the top of my head, I can't remember what I exactly fixed.  I remember something about undeclared variables or something-or-other and what you listed sounds like it was one of the issues I found with the mod during a live test on my own website....

RSI

#43
Is there anyway to remove the space between the inline image and the download link and counter?

Normally it's right underneath the image, but its adding a space for some reason.

Other than that everything works fine now.

See an example of what I'm getting attached below...


RSI

I found it...

Don't know if it was an intentional personal preference thing or just a carryover that was missed but there is a <br /> and a <br/> in the Subs-InlineAttachments.php code below.

Removing the one last <br/> solves it and the links are displayed right under images now. I removed both of them.

Find
// Highslide Image Viewer Installed?
elseif (function_exists('highslide_images'))
$html = '<a href="' . $image . ';image" id="link_' . $id . '" class="highslide" rel="highslide"><img src="' . $thumb . '" ' . $width . $height . ' alt="' . $attachment['name'] . '"' . $float . $margin . ' id="thumb_' . $id . '" /></a><br /><span class="highslide-heading">' . $context['subject'] . '</span>';
// jQLightbox
elseif (!empty($modSettings['enable_jqlightbox_mod']) && strpos($context['html_headers'], 'jquery.prettyPhoto.css'))
$html = '<a href="' . $image . ';image" id="link_' . $id . '" rel="lightbox[gallery]"><img src="' . $thumb . '" ' . $width . $height . ' alt="' . $attachment['name'] . '"' . $float . $margin . ' id="thumb_' . $id . '" /></a>';
// Simple Mode
else
$html = '<img src="' . $thumb . ';image" alt=""' . $width . $height . ' alt="' . $attachment['name'] . '"' . $float . $margin . ' class="bbc_img resized" />';
}
else
$html = '<img src="' . $thumb . ';image" alt=""' . $width . $height . ' alt="' . $attachment['name'] . '"' . $float . $margin . ' class="bbc_img resized" />';

// Add the download count to the image tag if requested:
if (!empty($modSettings['ila_download_count']) && $tag['tag'] != 'attachmini')
$html .= '<br/><div class="smalltext"><a href="' . $image . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" />&nbsp;' . $attachment['name'] . '</a> ('. $attachment['size']. ($attachment['is_image'] ? '. ' . $src_width . 'x' . $src_height . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)</div>';


Replace with
// Highslide Image Viewer Installed?
elseif (function_exists('highslide_images'))
$html = '<a href="' . $image . ';image" id="link_' . $id . '" class="highslide" rel="highslide"><img src="' . $thumb . '" ' . $width . $height . ' alt="' . $attachment['name'] . '"' . $float . $margin . ' id="thumb_' . $id . '" /></a><span class="highslide-heading">' . $context['subject'] . '</span>';
// jQLightbox
elseif (!empty($modSettings['enable_jqlightbox_mod']) && strpos($context['html_headers'], 'jquery.prettyPhoto.css'))
$html = '<a href="' . $image . ';image" id="link_' . $id . '" rel="lightbox[gallery]"><img src="' . $thumb . '" ' . $width . $height . ' alt="' . $attachment['name'] . '"' . $float . $margin . ' id="thumb_' . $id . '" /></a>';
// Simple Mode
else
$html = '<img src="' . $thumb . ';image" alt=""' . $width . $height . ' alt="' . $attachment['name'] . '"' . $float . $margin . ' class="bbc_img resized" />';
}
else
$html = '<img src="' . $thumb . ';image" alt=""' . $width . $height . ' alt="' . $attachment['name'] . '"' . $float . $margin . ' class="bbc_img resized" />';

// Add the download count to the image tag if requested:
if (!empty($modSettings['ila_download_count']) && $tag['tag'] != 'attachmini')
$html .= '<div class="smalltext"><a href="' . $image . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" />&nbsp;' . $attachment['name'] . '</a> ('. $attachment['size']. ($attachment['is_image'] ? '. ' . $src_width . 'x' . $src_height . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)</div>';

// Clear the parameter set for the next usage and return string to caller:
unset($context["ila_params"]);
return $html;
}

dougiefresh

Uploaded v2.3 - December 28th, 2014
o Performance enhancement due to storing permission check after first check.
o Fixed spacing issues between picture and download counter/link.  Thanks, RSI!

RSI

Hey, thank you very much for creating and updating this mod. I've been waiting for someone to finally do it!!!

I tied using the HS4 and ILA mods a while back, but I already had the Highslide mod installed and modified at the time and there were conflicts trying to add them after.

Anyway, this should be a standard feature built-into SMF period!!! I cannot really say anything more other than this one looks like it belongs with it.

Again, thanks...!!!





tranhiep_116

 thanks you very much for creating and updating this mod. I will using it for my smf ;D

dougiefresh

You're welcome! 

@RSI:  I agree with ya, but I have very serious doubts that SMF will ever incorporate this into the core code....  You never know, though....

RSI

Hi,

I wanted to give you an update on this. With version 2.2 installed I was still occasionally getting the errors and it it only happened on uploads where the server traffic or something appeared to be a little high when the uploads were slow. And when it happened it was always with a different line in the Subs-InlineAttachments.php file.

I recently uploaded the new 2.3 version of then Subs-InlineAttachments.php file and now it happens again every single time again, but it's always the same line now, line 523.

The error I get is below. Any idea on how to correct this?

http://mydomain.com/index.php?action=post2;start=25;board=7

8: Undefined index: subject

File: /home/me/public_html/Sources/Subs-InlineAttachments.php

Line: 523

dougiefresh

Uploaded v2.4 - January 11th, 2015
o Fixed undefined index error within Subs-InlineAttachments.php...

@RSI: This update should solve the issue you reported.  Thank you for the bug report!

RSI

K, that fixed it... Thanks...

Now I can just leave it alone for the next several years 8)


dougiefresh

Uploaded v2.5 - January 19th, 2015
o License change to Simplified BSD.  No functionality change.

RSI

#53
Hi, there is a problem with IE or at least with IE11. The images do not display. You can see the placeholders and when you click on them they pop up fine and display if using Highslide, but the in-line images are not displaying within posts themselves.

I never checked it on IE before and all I have is IE11 so I'm not sure if it also effects IE10, 9, etc. but it's definitely a big problem if using IE11. I had a couple of users complain so I just looked at it and can see the problem. I even tried using compatibility mode and it starts to resize the images properly when doing that, but you still only see the placeholders. Everything is fine when using Safari or Firefox, just not with IE11 and possibly earlier.

P.S. I just manually went through and updated to the latest version 2.5 and it's still the same, wont display the images in-line with IE11. Can only see the placeholders.

dougiefresh


RSI

Update, it's doing the same thing with IE8. Hope that helps...


Arantor

I haven't dug into the mod... but related question: when you serve attachments, are you serving them through dlattach? More importantly... when you serve the attachment, do you have the correct Content-Type header being sent? IE8+ will choke on a file when there is an incorrect/missing content-type header declaration versus what the file contains. E.g. if you serve it a picture, the Content-Type needs to match the picture otherwise IE will refuse to show the picture. (Even if you tell it the image is a JPEG when the file is really a PNG for example)

RSI

Below is an example of what's being sent to the browser.

<a href="http://mydomain.com/index.php?action=dlattach;topic=207.0;attach=1173;image" id="link_0" class="highslide" rel="highslide"><img src="http://mydomain.com/index.php?action=dlattach;topic=207.0;attach=1173" &nbsp;width="300" height="183" alt="RF_Deck_Mod_01.png" id="thumb_0"></a>

<span class="highslide-heading">My Topic</span>

<div class="smalltext"><a href="http://mydomain.com/index.php?action=dlattach;topic=207.0;attach=1173"><img src="http://mydomain.com/Themes/default/images/icons/clip.gif" align="middle" alt="*" border="0">&nbsp;RF_Deck_Mod_01.png</a> (79.38 kB. 300x183 - viewed 352 times.)</div>


I don't have anything earlier than IE8 so I don't know about IE7, but its probably a pretty safe bet to assume it's not working from IE8 on up to IE11. It's doing the exact same thing on IE8 and IE11 both.

I remember all of those different Content-Type headers for IE a while back and some where on the main index page or template, but I think those were all eventually removed, right? I assume you are talking about adding them somewhere else for this mod...?

Arantor

Yes, I'm not talking about anything on the page itself that you're looking at, I'm talking about the physical request/response for actually sending the file.

As a temporary test to prove whether this is the root cause, take a look in the top level index.php file.

You'll see this line:
header('X-Content-Type-Options: nosniff');

If you remove that line temporarily and try it again, does it work?

RSI

Quote from: Arantor on January 20, 2015, 10:28:45 AM
Yes, I'm not talking about anything on the page itself that you're looking at, I'm talking about the physical request/response for actually sending the file.

As a temporary test to prove whether this is the root cause, take a look in the top level index.php file.

You'll see this line:
header('X-Content-Type-Options: nosniff');

If you remove that line temporarily and try it again, does it work?

Yep, it's works if I comment out that line ;)

Advertisement: