How to display attachments in external page

AndyB

Well-known member
I have a mobile site that I wrote which is optimized for mobile users. When I display a thread in any post which has an attachment I parse the attachment code and replace it with HTML <img src> code to display the image, however this only works with the thumbnail images.

The problem is that thumbnails images are very low resolution. What is the best way to display a full size attachment, I can't make the path to the full size attachments files because the extension used there is .data and will not display.

Thank you.
 
Refer to the bb_code_tag_attach template. This is the code for an inline full-sized attached image:

Code:
<img src="{xen:link attachments, $attachment}" alt="{$attachment.filename}" class="bbCodeImage LbImage" />

It uses xen:link to build a URL using the "attachments" route. It doesn't address the data file directly.
 
I got a little further with my effort to display a full size attachment in an external page. If I use this code...

Code:
<?php
header('Content-Type: image/jpeg');
 
$get_image_data = file_get_contents('/home/path/to_my_file/forums/internal_data/attachments/0/1-b5b8dadf8a210bda593e1bde2abbfb7a.data');
 
echo $get_image_data;
?>

...it will display the image. Now to try and figure out how to use this code in a webpage along with text.
 
Interesting route you're taking, despite Jake's advice.

If the image you want to display in an external page has an attachment_id of 1 (which I think your code example above does based on the 1- prefix) then you need to do nothing more than this:

<img src="http://your-site.com/attachments/1" />

There's no need at all to interact with the raw data.
 
Refer to the bb_code_tag_attach template. This is the code for an inline full-sized attached image:

Code:
<img src="{xen:link attachments, $attachment}" alt="{$attachment.filename}" class="bbCodeImage LbImage" />

It uses xen:link to build a URL using the "attachments" route. It doesn't address the data file directly.


Hi Jake. I am trying to teach myself more about how add-ons work in Xenforo. I have a custom add-on (and the author is currently unavailable for a while to make a change) where we are using an attachment from a post on another page. The author was pulling the thumbnail so the image is a very low resolution.

<img src="{$item.thumbnailUrl}" alt="{$item.filename}" class="Thumbfeatured" data-src="{$item.filename}">
What can I call to reference the full image itself and resize instead of just the thumbnail? The thumbnails are coming over at about 100x100 and I just need something 150x150 to look much better. Thanks for the help!
 
Top Bottom