Inline / Horizontal Attachment Thumbnails

Started by smartdaz9682, July 22, 2016, 02:20:48 PM

Previous topic - Next topic

smartdaz9682

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!

Irisado

Welcome to SMF :).

Could you please confirm which version of the software are you using?  Stating current is too vague.
Soñando con una playa donde brilla el sol, un arco iris ilumina el cielo, y el mar espejea iridescentemente

smartdaz9682

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.

Kindred

there is a mod for 2.0.x to allow inline attachments
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

smartdaz9682

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.



smartdaz9682

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?

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

smartdaz9682

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.

Grammy

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?

Kindred


// 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
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

lurkalot


Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

crimpson

Kindred
Which files are being edited? it this the display template?

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: