Random Image Attachment Banner

Started by madman71, May 02, 2010, 03:14:21 AM

Previous topic - Next topic

madman71

Link to Mod

Random Image Attachment Banner


This mod will pull thumbnail attachments to the top of every page on your forum.  By default, it is set to display 6 thumbnails (side by side) in a banner style container. Each thumbnail in the banner is clickable and leads to the post where it was attached.
Some might ask how is this banner mod different from say the Recent Image Attachments function that is found in SIMPLE PORTAL?
The difference is that my banner mod will actually link to the post where the thumbnail is located.  The SimplePortal mod function only links to the attachment and NOT the post. This is no longer true. SP will link to the actual post where the image attachment is found.



This mod works only with SMF 2.0 RC3 (It has not been tested on any other SMF 2.0's)
There are no permission settings in the admin panel.  This mod works right out of the box. 



I had this mod custom made and was given permission from the author to disperse it. I am limited on the support that i can give with this mod.  My programming skills are very limited.  If any coder wants to take this mod over and expand on it's possibilities, just let me know.  ;D


DEMO DEMO no longer avail
SEE SCREEN SHOT BELOW



Screenshot:







madman71

IF anyone has any problems installing this mod, Plz let me know  ;D

Should be an easy install

diontoradan

nice mod, i wish you could have arrangements settings, newest attachment, random, by category, and select display from certain boards...

ProfDrDenis

super.

But better is the pics are showing with a small size. Any idea what is todo?


ProfDrDenis

Quote from: madman71 on May 23, 2010, 06:15:34 PM
what do you mean "todo"?

on which place I put what so that the pics are - for example - have a width from 300x

madman71

You want to have the thumbnails displayed at 300px wide in the banner??
or do you want the entire banner displayed at 300px wide?

ProfDrDenis

Quote from: madman71 on May 24, 2010, 12:55:52 PM
You want to have the thumbnails displayed at 300px wide in the banner??
or do you want the entire banner displayed at 300px wide?

not the banner, the pics! With the pics like 1024x the style is not nice

madman71

I looked at the code in the BOARDATTACHMENTS.PHP and could not find any place where you can change the dimensions of the displayed thumbnails.

I'll post the code here.  Maybe someone with an eye for code and spot it for you:


I was looking at this part, but i think it has to do with the actual file size and not dimensions.
'filesize' => round($row['filesize'] /1024, 2) . $txt['kilobyte'],

BOARDATTACHMENTS.PHP

function get_recent_attachments()
{
global $smcFunc, $context, $modSettings, $scripturl, $txt, $settings;

$num_attachments = 6;
$attachment_ext = array('jpg', 'jpeg', 'png', 'gif', 'bmp');

$attachments_boards = boardsAllowedTo('view_attachments');

if (empty($attachments_boards))
return;

if (!is_array($attachment_ext))
$attachment_ext = array($attachment_ext);

$request = $smcFunc['db_query']('', '
SELECT
att.id_attach, att.id_msg, att.filename, IFNULL(att.size, 0) AS filesize, att.downloads, mem.id_member,
IFNULL(mem.real_name, m.poster_name) AS poster_name, m.id_topic, m.subject, t.id_board, m.poster_time,
att.width, att.height' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ', IFNULL(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height') . '
FROM {db_prefix}attachments AS att
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = att.id_msg)
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : '
LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = att.id_thumb)') . '
WHERE att.attachment_type = 0' . ($attachments_boards === array(0) ? '' : '
AND m.id_board IN ({array_int:boards_can_see})') . (!empty($attachment_ext) ? '
AND att.fileext IN ({array_string:attachment_ext})' : '') .
(!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}
AND att.approved = {int:is_approved}') . '
ORDER BY RAND()
LIMIT {int:num_attachments}',
array(
'boards_can_see' => $attachments_boards,
'attachment_ext' => $attachment_ext,
'num_attachments' => $num_attachments,
'is_approved' => 1,
)
);

$context['recent_attachments'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$filename = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($row['filename']));

$context['recent_attachments'][$row['id_attach']] = array(
'member' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>',
),
'file' => array(
'filename' => $filename,
'filesize' => round($row['filesize'] /1024, 2) . $txt['kilobyte'],
'downloads' => $row['downloads'],
'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'],
'link' => '<img src="' . $settings['images_url'] . '/icons/clip.gif" alt="" /> <a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $filename . '</a>',
'is_image' => !empty($row['width']) && !empty($row['height']) && !empty($modSettings['attachmentShowImages']),
),
'topic' => array(
'id' => $row['id_topic'],
'subject' => $row['subject'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>',
'time' => timeformat($row['poster_time']),
),
);

if ($context['recent_attachments'][$row['id_attach']]['file']['is_image'])
{
$id_thumb = empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb'];
$context['recent_attachments'][$row['id_attach']]['file']['image'] = array(
'id' => $id_thumb,
'width' => $row['width'],
'height' => $row['height'],
'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image" alt="' . $filename . '" />',
'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />',
'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image',
'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" /></a>',
);
}
}
$smcFunc['db_free_result']($request);

if (!empty($context['recent_attachments']))
{
loadTemplate('BoardAttachments', 'board_attach');
$context['template_layers'][] = 'board_attach';

ProfDrDenis


madman71

Quote from: ProfDrDenis on May 25, 2010, 09:14:41 AM
Quote from: madman71 on May 24, 2010, 12:55:52 PM
You want to have the thumbnails displayed at 300px wide in the banner??
or do you want the entire banner displayed at 300px wide?

not the banner, the pics! With the pics like 1024x the style is not nice

Looking again and your question, it looks like you want large pictures? You want several large images to be displaying IN the banner?

ProfDrDenis

no,

now the random pics have the original size from the topic (see my attach) and this is to big! this looks not nice. So my idea is to change the size from the pics ..

madman71

could you send me a link to your forum where that picture is?

either here or via PM

ProfDrDenis

you must know the mod is just install in my test forum http://blog.afrikafrika.de/

user: chef
password: substitute


madman71

send me a link to this post so i can see the thumbnail in your attachment.

also, where is the banner?

ProfDrDenis

Quote from: madman71 on June 04, 2010, 11:03:43 AM
also, where is the banner?

You dont see? look in the bottom from the test forum or look to my attach pic. and than you click on the pic and you see the post or? but the pic in the post is 800xXX pixel

madman71

This is all i can see:

http://imagesocket.com/view/Test_FORUM_Index_1275863844605438.jpg


I can login with the popup box, but not at the actual forum itself.

Reefer

#17
Madman... wonder if you can help...


installed your mod and it works great except there is a slight aberration in the display... check:
EDITTED OUT
The frame underneath the thumbnails is out? any idea what to do?

madman71

Reef,

I do not see the banner on your site also.

Reefer

PM'd you login details. It seems guests don't get to see the Banner??

Advertisement: