News:

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

Main Menu

Image preview to guest

Started by kkmixs, November 09, 2013, 10:52:28 PM

Previous topic - Next topic

kkmixs

Hello

I have managed to show the attachment to guest but when the attachement is a image, then it is not showing the preview thumbnail.

In simple word: My vistor can see the attachement, if they click on attachment it will redirect it to the log in page.

But when i attached the image to the post, it donot show the  image thumbnail to the guest instead it only show the attachemnet file name link:

Please look the attached image at my forum:
http://forum.embroideryshristi.com/designs-search/test-1455/

you will see the image attached but not the thumbanial.

So how to allow my guest to see the image thumbanial.

mashby

What mods do you have installed? This is the code from a typical 2.0.x installation for attachments in Display.template.php:
if ($attachment['is_image'])
{
if ($attachment['thumbnail']['has_thumb'])
echo '
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" /></a><br />';
else
echo '
<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '"/><br />';
}
Are you able to see the thumbnail on that link you supplied?
Always be a little kinder than necessary.
- James M. Barrie

kkmixs

Hello thanks for the reply.Actually i m not using any mod.I have made a small modification to my display.php as stated by Shadow82x at the below link:
http://www.simplemachines.org/community/index.php?topic=332299.0

By using above coding my Guest are  able to see the attachement but they can not see the preview of image attachement. So , how to show the thumbainala preview of attachement to guest???

Please note that in above code i have changed the

  $modSettings['attachmentShowImages'] = 0;

to

  $modSettings['attachmentShowImages'] = 1;

It will show the image to the guest but still not able to preview the image.

Please have a look over my forum.Since you are guest you can see the attachement at my forum but can't see the preview.Sorry i have deleted the post at the previous link.But for testing purpose i have added a new post, you can visit for the same:
http://forum.embroideryshristi.com/embroideryshristi-projects/elegant-neckline-embroidery-project/

margarett

#3
I was looking at this.

It's a little bit more tricky because the link to the thumb is generated but the image is not loaded (checked with firebug). This is an issue with the permissions you are trying to cheat :P

edit: although I wouldn't recommend this, you can easily achieve it again in Display.php

else
{
// This checks only the current board for $board/$topic's permissions.
isAllowedTo('view_attachments');

Comment out the "isAllowedTo" line and there you have it, a thumbnail for guests.
BUT with this, the user can click the thumbnail and it opens full size. You don't want that, do you?
So, go to Display.template.php and:
Find:

if ($attachment['thumbnail']['has_thumb'])
echo '
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" /></a><br />';

Replace with:
if ($attachment['thumbnail']['has_thumb'])
{
if ($context['user']['is_guest'])
echo '
<img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" /><br />';
else
echo '
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" /></a><br />';
}
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

kkmixs

It doesnot work. it completely remove the image.Intially there was  image but it was not loading now even there is no image.

margarett

It has to work, sorry, I tested it...

Check the changes you've made ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Oldiesmann

It's not as simple as a few changes to the template file. SMF doesn't even bother loading attachment data if you can't view attachments, for obvious reasons.

This should make it so that only data for image attachments is loaded for guests (just in case you have any attachments which aren't images):

Sources/Display.php

Find
if (!empty($modSettings['attachmentEnable']) && allowedTo('view_attachments'))

Replace
if (!empty($modSettings['attachmentEnable']) && (allowedTo('view_attachments') || $context['user']['is_guest']))

Find
AND a.attachment_type = {int:attachment_type}',

Replace
AND a.attachment_type = {int:attachment_type}' . $context['user']['is_guest'] ? ' AND a.fileext IN ({array_string:image_types})' : '',

Find
'is_approved' => 1,

Add after that
'image_types' => array('jpg', 'jpeg', 'gif', 'png'),
Michael Eshom
Christian Metal Fans

margarett

 :o
Strange... My test board is showing it with the changes I proposed...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

kkmixs

Oldiesmann:

If you used the coding recommended by you then i get the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND a.fileext IN ('jpg', 'jpeg', 'gif', 'png')' at line 1

Line: 967

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 2.0.5, while your database is at version 2.0.4. The above error might possibly go away if you execute the latest version of upgrade.php.

Oldiesmann

Quote from: kkmixs on November 15, 2013, 01:00:52 PM
Oldiesmann:

If you used the coding recommended by you then i get the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND a.fileext IN ('jpg', 'jpeg', 'gif', 'png')' at line 1

Line: 967

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 2.0.5, while your database is at version 2.0.4. The above error might possibly go away if you execute the latest version of upgrade.php.

Can you attach your copy of Display.php?
Michael Eshom
Christian Metal Fans

kkmixs

Please find the attache copy of my Display.php

Please note that it is a core theme with version 2.0.5

margarett

You should really update your forum ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Oldiesmann

Michael Eshom
Christian Metal Fans

kkmixs

Sorry for the late reply.No it does not work..It does not make any changes at all.Everything appear same even after using the display.php given by you.


kkmixs

Hey finally  i managed to do it.I have allowed my guest to view the image and even install the inline attachment.But i m facing a one more problem. My inline attachement is not shown to guest.When my guest visit the forum they are shown a message

I have used the following coding for my inline module installation:

http://custom.simplemachines.org/mods/index.php?action=parse


I am not able to find the way out to remove the permission coding and allow the guest to see the image.Can anyone can help me that which part should i delete to allow the guest to see my inline attachement. Please note by default my guest can see the image attachement but he cannot see the inline attachement.

you can see the live at my website at
http://forum.embroideryshristi.com/embroidery-software/how-to-center-the-designs-using-auto-start/

You can see the image attachement but you can't see the inline attachement.Please have a look over the coding given above link


thanks in advanvce

margarett

That is the kind of question you need to ask in the MOD support topic ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

kkmixs

I have already asked there, i share it here, if someone can help me.Thanks for the all support.Thanks a lot.

ElDudo

Quote from: kkmixs on November 19, 2013, 11:22:40 PM
Hey finally  i managed to do it.I have allowed my guest to view the image and even install the inline attachment.But i m facing a one more problem. My inline attachement is not shown to guest.When my guest visit the forum they are shown a message

I have used the following coding for my inline module installation:

http://custom.simplemachines.org/mods/index.php?action=parse


I am not able to find the way out to remove the permission coding and allow the guest to see the image.Can anyone can help me that which part should i delete to allow the guest to see my inline attachement. Please note by default my guest can see the image attachement but he cannot see the inline attachement.

you can see the live at my website at
http://forum.embroideryshristi.com/embroidery-software/how-to-center-the-designs-using-auto-start/

You can see the image attachement but you can't see the inline attachement.Please have a look over the coding given above link


thanks in advanvce

Hi there,

Can I ask you, which of the coding suggestions in this thread did you use to have image preview for guests? I have looked around, and your thread is among the few threads that cover this topic and it is by far the most recent.

I would appreciate if you could let me/us know what was it that you did that got this going.

Many thanks.

kkmixs

I have install the mod muanually using this prase of guest preview

http://custom.simplemachines.org/mods/index.php?action=parse


Note: I have follow the steps given in Display.php file only.By doing the changes given in Display.php file only, my guest are able to see the attachment as well as preview of image and when they click on it, they will be redirect to the log in page.

You may proceed to the other coding if you want to show them a message that 'Log in to Download', but i think redirecting to log to log in page is enough for you....

Arantor

That's not a valid link... you need to link to the page *before* you pressed 'Parse'...

kkmixs


Arantor

Some extremely interesting observations in the "support and comments for this mod" thread...

Advertisement: