Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: smartdaz9682 on July 22, 2016, 02:20:48 PM

Title: Inline / Horizontal Attachment Thumbnails
Post by: smartdaz9682 on July 22, 2016, 02:20:48 PM
Hey guys. This is a question that seems to get asked a lot. The older versions of SMF you could change the display,template.php file quite easily however I've not been able to do it in the current version since the code to replace doesn't seem to be the same.

Any help would be highly appreciated as having to keep scrolling down to see all the thumbnails is quite annoying.  Thanks!
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: Irisado on July 22, 2016, 02:23:44 PM
Welcome to SMF :).

Could you please confirm which version of the software are you using?  Stating current is too vague.
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: smartdaz9682 on July 22, 2016, 02:40:58 PM
Quote from: Irisado on July 22, 2016, 02:23:44 PM
Welcome to SMF :).

Could you please confirm which version of the software are you using?  Stating current is too vague.

Hi. Thank you! :)

Certainly. I am using SMF 2.0.11 right now.
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: Kindred on July 22, 2016, 05:30:51 PM
there is a mod for 2.0.x to allow inline attachments
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: smartdaz9682 on July 24, 2016, 07:21:25 PM
Quote from: Kindred on July 22, 2016, 05:30:51 PM
there is a mod for 2.0.x to allow inline attachments

Any idea to the name of that? The ones I found were all for older versions of SMF and didn't work.
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: Illori on July 24, 2016, 07:24:14 PM
https://github.com/Spuds/SMF-ILA
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: br360 on July 24, 2016, 07:38:48 PM
There is also this mod- http://custom.simplemachines.org/mods/index.php?mod=3770
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: smartdaz9682 on July 25, 2016, 09:09:25 PM
Unfortunately neither of those do what I need.

the SMF mod only works on new attachments and you need to insert an attachment code for every single one as it's not default. I'd have to inform all my users to also do that every time to which is a big hassle.

And the github one only works on the default theme unless you edit the custom theme too which brings me back to square one.

Is there really no simple "edit the template.display" method like there was before?
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: Kindred on July 25, 2016, 09:39:52 PM
No
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: smartdaz9682 on July 26, 2016, 01:06:10 PM
Quote from: Kindred on July 25, 2016, 09:39:52 PM
No

Well that's disappointing. It's such a vastly asked for feature as the vertical placements of attachments looks so bad. That's a shame.
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: Grammy on July 26, 2016, 01:14:55 PM
Quote from: smartdaz9682 on July 26, 2016, 01:06:10 PM
Well that's disappointing. It's such a vastly asked for feature as the vertical placements of attachments looks so bad. That's a shame.



I was just curious about which theme you use?
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: Kindred on July 26, 2016, 02:22:02 PM

// Assuming there are attachments...
if (!empty($message['attachment']))
{
echo '
<div id="msg_', $message['id'], '_footer" class="attachments smalltext">
<div style="overflow: ', $context['browser']['is_firefox'] ? 'visible' : 'auto', ';">';

$last_approved_state = 1;
foreach ($message['attachment'] as $attachment)
{
// Show a special box for unapproved attachments...
if ($attachment['is_approved'] != $last_approved_state)
{
$last_approved_state = 0;
echo '
<fieldset>
<legend>', $txt['attach_awaiting_approve'];

if ($context['can_approve'])
echo '&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';

echo '</legend>';
}

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 />';
}
echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" />&nbsp;' . $attachment['name'] . '</a> ';

if (!$attachment['is_approved'] && $context['can_approve'])
echo '
[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
echo '
(', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />';
}

// If we had unapproved attachments clean up.
if ($last_approved_state == 0)
echo '
</fieldset>';

echo '
</div>
</div>';
}


Code (change to) Select

// Assuming there are attachments...
if (!empty($message['attachment']))
{
echo '
<div id="msg_', $message['id'], '_footer" class="attachments smalltext">
<div style="overflow: ', $context['browser']['is_firefox'] ? 'visible' : 'auto', ';">';
echo '<ul class="inline-attachments">';
$last_approved_state = 1;
foreach ($message['attachment'] as $attachment)
{
// Show a special box for unapproved attachments...
if ($attachment['is_approved'] != $last_approved_state)
{
$last_approved_state = 0;
echo '
<fieldset>
<legend>', $txt['attach_awaiting_approve'];

if ($context['can_approve'])
echo '&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';

echo '</legend>';
}

if ($attachment['is_image'])
{
echo '<li class="inline-attachment" id="attachment_', $attachment['id'], '">';
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 />';
}
echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" />&nbsp;' . $attachment['name'] . '</a> ';

if (!$attachment['is_approved'] && $context['can_approve'])
echo '
[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
echo '
<br />- ', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' <br />- ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.</li>';
}

// If we had unapproved attachments clean up.
if ($last_approved_state == 0)
echo '
</fieldset>';
echo '</ul>';
echo '
</div>
</div>';
}





Code (css additions) Select

.inline-attachment {
    display: inline-block;
    width: 150px;
}
.inline-attachments {
    list-style-type: none;
}


displays like this...
http://test.turtleshellprod.com/index.php?topic=61.0
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: lurkalot on July 26, 2016, 02:45:11 PM
Quote from: Kindred on July 26, 2016, 02:22:02 PM

displays like this...
http://test.turtleshellprod.com/index.php?topic=61.0

Don't think guests can see attachments on there in your example, or at least I can't.
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: Kindred on July 26, 2016, 03:41:07 PM
fixed that -- thanks
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: crimpson on August 19, 2016, 07:15:21 PM
Kindred
Which files are being edited? it this the display template?
Title: Re: Inline / Horizontal Attachment Thumbnails
Post by: Kindred on August 20, 2016, 08:23:28 PM
yes and index.css