Mybb: Problem with attachment.php

Created on 1 Sep 2018  路  5Comments  路  Source: mybb/mybb

I've discovered an issue involving attachment.php which likely impacts most image-centric sites:

  • Please bear in mind that I'm not a programmer -- the essence of what I'm saying appears to be correct but my theory/explanation might be somewhat inaccurate

I rely heavily on thumbnails (an average thread page on my site contains around 50) -- the image source for thumbnails runs attachment.php (src="attachment.php?thumbnail=100320").

Once a thread loads, attachment.php is executed for聽every single thumbnail and pulls the proper聽AID from a string (PID-based) generated in showthread.php. In other words, MyBB pulls thumbnail images through an intermediate script. As you can imagine, when attachment.php is loaded 50 times by ONE user in response to loading one page (on a forum with around 100 guests and members browsing around) the whole thing bogs down. I understand the intent (my guess is to conceal actual files names) but it's a huge waste of resources.

Does anyone know of a concrete way of modifying showthread.php to simply echo the path, name and format of thumbnail images (which are stored in uploads) and link them to the appropriate attachment ID inside a post? Under this configuration, only after clicking a thumbnail would attachment.php run -- the browser would pull thumbnail images directly. The downside is the location and names of image files would be visible.

Alternatively, maybe there's a way of handling thumbnails with a separate script that's called once per post (one time for multiple thumbnails).

This seems to be the reason my site runs like crap.

Original thread: Problem with attachment.php

1.9 confirmed bug

All 5 comments

My simple and alternative solution is available for this problem. Open the postbit templates for the theme you are using and replace the code in the file postbit_attachments_thumbnails_thumbnail with the code below.

<a href="uploads/{$attachment['thumbnail']}" target="_blank"><img src="uploads/{$attachment['thumbnail']}" class="attachment" alt="" title="{$lang->postbit_attachment_filename} {$attachment['filename']} {$lang->postbit_attachment_size} {$attachment['filesize']} {$attachdate}" /></a>&nbsp;&nbsp;&nbsp;

One possible approach could be to stop loading global.php and instead go with a similar route as the xmlhttp.php file.

@dvz is it a bug? I guess its an enhancement or optimization?

I'd say this should be a enhancement for optimization.

Regarding using {$attachment['thumbnail']} in templates as suggested above, this could lead users to guess the full image path and ultimately getting access to download it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Eldenroot picture Eldenroot  路  4Comments

RikoDEV picture RikoDEV  路  3Comments

euantorano picture euantorano  路  4Comments

LogicPlague picture LogicPlague  路  5Comments

effone picture effone  路  5Comments