News:

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

Main Menu

image attachment issue

Started by Johno69, May 27, 2008, 12:13:37 AM

Previous topic - Next topic

Johno69

I have an issue with image attachments.

The images attach fine, and I can see the image preview (thumb) and when I click the attachment file name it saves to my computer and opens fine.

BUT, when I click the thumbnail of the attachment it gives a 404 page.

the only difference in URLs i can see is the ;image  placed at the end.

index.php?action=dlattach;topic=3083.0;attach=917;image   -->   doesn't work
index.php?action=dlattach;topic=3083.0;attach=917    --> downloads

I'd like to be able to see the picture in full view when clicking the ;image link.

Any idea's?

karlbenson

Version of SMF?
What mods are you using?
Can you link to a topic where this is happening?

Johno69

i'm using 1.1.2 and have tried to upgrade but the package manager reports issues. So i've been reluctant to upgrade.

Bridged with joomla and has been happening a while, back when the only mod installed was the custom profile mod.

Can't really link to a topic as guest browsing has been disabled via is_not_guest()

I guess I can make a temp account if required.

Rumbaar

Yes a temp account would be required for us to be able to fully test it.  Did it ever work?
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Johno69

#4

Rumbaar

Quote from: Rumbaar on June 23, 2008, 06:10:28 AMDid it ever work?
You have the image opening up in a new window, when the code is meant (I'm sure) to expand/open the image inline.  As it use javascript to resize I'm sure this is why you get an error.

When you access the link directly it works, with the ;image suffix
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Johno69

Is there a setting to have it open inline? I can't remember setting anything.

Rumbaar

Not that I'm aware of.  It might be a feature of the bridge or a mod you've installed.

Like I've asked twice now, did it ever work?
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Johno69

Not that I remember... I don't think it ever worked.

Rumbaar

What are the mods you have installed?  I'm not aware of the changes the bridge does to base SMF code, so not sure of what might be causing this.  You might want to ask in the Joomla section to see if other users have ever experienced this issue or search there.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Johno69

I have a few mods installed, but generally installed them after I found this issue.

I will post this in the bridge section too though.

Do you know where the code would be i'd been to edit to make it remove the ;image off the url so it simply downloads it either way ?

Rumbaar

Not sure of the implications of removing that detail from the image generation, but it's found in
SourcesDisplay.php
~Line 1207 :                'href' => $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attachment['ID_THUMB'] . ';image',
~Line 1229 :                $attachmentData[$i]['thumbnail']['javascript'] = "return reqWin('" . $attachmentData[$i]['href'] . ";image', " . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';

SourcesManageAttachments.php
~Line 342 :             'link' => '<a href="' . ($row['attachmentType'] == 1 ? $modSettings['custom_avatar_url'] . '/' . $row['filename'] : ($scripturl . '?action=dlattach;' . ($context['browse_type'] == 'avatars' ? 'type=avatar;' : 'topic=' . $row['ID_TOPIC'] . '.0;') . 'id=' . $row['ID_ATTACH'])) . '"' . (empty($row['width']) || empty($row['height']) ? '' : ' onclick="return reqWin(this.href + ';image', ' . ($row['width'] + 20) . ', ' . ($row['height'] + 20) . ', true);"') . '>' . htmlspecialchars($row['filename']) . '</a>'
Depending on the theme, Display.template.php
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" border="0" /></a><br />';
<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" border="0" /><br />';
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Johno69

I just started testing removing thos references and realised the issue does look to be with the bridge.

When using the link without the ;image it calls to the upbridge (unwrapped?) url of

index.php?action=dlattach;topic=655.0;attach=567

But when clicking the image it changes to the bridged url

index.php?option=com_smf&Itemid=26&?action=dlattach;topic=655.0;attach=567;image

Now things are starting to narrow down.


Johno69

I guess I could just hard code the URL somehow.

// If the image is too large to show inline, make it a popup.
if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height'])))
$attachmentData[$i]['thumbnail']['javascript'] = "return reqWin('" . $attachmentData[$i]['href'] . ";image', " . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';


In there somehow.


Johno69

#14
I've just enabled thumbnails..

So this line is what I need to edit.

'href' => $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attachment['ID_THUMB'] . ';image',

would it be

'href' => 'http://forum/index.php?action=dlattach;topic=' . $topic . '.0;attach=' . $attachment['ID_THUMB'] . ';image',

I'll test and see anyway.

Update: didnt work :(

Update 2:

I changed

'href' => $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attachment['ID_ATTACH'],

to:

'href' => $boardurl . '/forum/index.php?action=dlattach;topic=' . $topic . '.0;attach=' . $attachment['ID_ATTACH'],

And it's working again.

Thanks for all your help, you pointed me in the right direction.

Johno69

8: Undefined variable: boardurl


I guess my fix was no good.

Rumbaar

Try taking out $boardurl . '
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Johno69

I had to leave the '

   'href' => '/forum/index.php' . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attachment['ID_ATTACH'],

Seems ok, no errors in log so far.

Awesome. This has been annoying me for over a year.

Many thanks.

Advertisement: