News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

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??

madman71

Ok, there's a couple things we can do in which i think i can assist.
1. We can make the banner wider but it go beyond the width of the forum
2. we can cut down the number of image permitted to be displayed in the banner (down to 5 maybe)
3. Not a fix, but we can change what type (format) of images to be displayed in the banner (i.e. portrait or landscape)


When i used this mod, i removed all landscape images from it (just for aesthetics) and cut down the number of images displayed.  This was for me thought :)

one final, possible solution: I noticed that you are using SimplePortal 2.3.2.  I have have stopped using my own mod and i now use SP random attachment banner.  Basically, it does the same thing as mine does, but has way more functions.

I can probably help you which ever method you take.

Reefer

Where can I find the Simple Portal one? Lets give it a bash. If it doesn't work, I'm coming after you...Lol!

madman71

It's in the ADMIN section of SMF

Look under SP settings.

Look at the image here:

If you need assistance setting it up, i can help

Reefer

Kewl, thanks for your help... I'll give it a bash! ;D


Reefer

OK... tried it but it doesn't link to the original post, right?
I we were to use yours, and limit it to 5 image attachments... how could we go about doing this?

madman71

it does the same exact thing that mine does, but come to think of it, i think you have to tweak the code to have it link directly to the post.  By default, it does not link directly to the post, only to the image.

To make the images link to the post, follow this
http://simpleportal.net/index.php?topic=4118.0

look for Sinan's post.  very small piece of code to replace

Reefer

Thanks once again Laurel... you be a champ!


kikkuvikings

willl it automatically show the latest topics / or i have to add the topics manually (if it is manually done , how can i select that option on smf 2.0RC3)
Padanilam [nofollow]

madman71

It will only show recent attachments in a banner format.
Look into simplePortal if you really want to have control (i.e. latest topics)
http://www.simpleportal.net/

dkharp

Great Mod! Can you set it to wear it does not pull the view board permissions? That way guest can see the pics too?  Also how do you set it to wear it will only show on the board not all the other pages. Im using TP and it shows up the front page..

Powered by SMF 2.0 RC3/TinyPortal 1.0 beta 5.2

Thanks!

madman71

Quote from: dkharp on November 06, 2010, 10:09:21 PM
Great Mod! Can you set it to wear it does not pull the view board permissions? That way guest can see the pics too?  Also how do you set it to wear it will only show on the board not all the other pages. Im using TP and it shows up the front page..

Powered by SMF 2.0 RC3/TinyPortal 1.0 beta 5.2

Thanks!

Im not sure what you mean by "does not pull the view board permissions".
This banner will display images to EVERYONE.  Even guests.  Now, if guests do not have permission to view attachments, then the banner thumbs will not be displayed.  ***NOTE** Guest must have permission to view attachments in posts in order for them to see this banner.

Im not the mod creator, i just paid to have this coded up for me.  When i told the programmer what i wanted, I told him that i wanted it to be displayed on all pages. There is no option to place it where you want it.

If you truly want full control over a banner style like mine, uninstall it my mod, and install http://www.simpleportal.net/
I know you are using TP, but SP has banner just like mine with millions of functions to tweak.
Might want to look into that.

if you want to see the SP banner in action, you can view my site: www.morningpeaches.us (This is an adult board with adult images) This banner is not randomized, but it can be set to.

Ciler

I have it working with the SP Block Recent Image Attachement but the Images are still!

Does somebody knows the code in PortalBlocks.php to make the images scrolling (moving)?



impreza

Interesting mod, thanks for making
Portal ToTemat.pl - treści w postaci artykułów i filmów tematycznych.

Biology Forums

Can someone make this work for 1.1.13 :( ?

Snowy

I love this, but the pictures are too big. I had to make it show only 3 pictures. I want them smaller, like 100 pixels. As it is now, 3 pictures goes the width of the forum. They asre just too big. How do I change the display size?

madman71

In your admin section, under ATTACHMENTS & AVATARS, what settings do you have for these:

Maximum width of thumbnails =
Maximum height of thumbnails  =

Snowy

I had them set at 250, but changed them to 100 and it didn't change the size of the pics.

madman71

well, im pretty certain it's a SMF setting and not a mod setting.  When i had it made, i had it made to display thumbnails from post attachments.

I highly recommend installing simple portal.  It has the a random image banner with much more functionality.



madman71

1.x will not happen.

Install Simple Portal, and you'll get your random image banner.

Biology Forums

Quote from: madman71 on April 04, 2011, 10:46:19 PM
1.x will not happen.

Install Simple Portal, and you'll get your random image banner.

Simple portal changes the dynamics of my website, so I'm not going to do that.

madman71

The only thing that i can think of that would change your site is that you would have a front entry page (portal) and the image banner anywhere or everywhere on your site. You would have way more banner placement options with SP.

with my banner, you are quite limited

Biology Forums

Quote from: madman71 on April 05, 2011, 02:20:22 PM
The only thing that i can think of that would change your site is that you would have a front entry page (portal) and the image banner anywhere or everywhere on your site. You would have way more banner placement options with SP.

with my banner, you are quite limited

I like your mod because I want to give users an idea of what people are uploading in threads. Maybe just the latest image upload and not necessarily a scrolls.

madman71

That's exactly what the SP image banner does. The SP banner does NOT scroll. it does exactly what mine does.  in fact, the writer of my mod is the writer of SP.

I dont run my mod anymore on my site, i use to the SP banner. There's more options.  If you want to see it in action i can let you view my site.

***it's a fine art adult site***

Biology Forums

Quote from: madman71 on April 05, 2011, 02:57:47 PM
T***it's a fine art adult site***

LOL, no thank you in that case. But I have seen a website in the past with it installed.

samozin

can u make it recent attached images from acertian board to be used on portal frontpage?

madman71

Quote from: samozin on April 09, 2011, 11:52:24 AM
can u make it recent attached images from acertian board to be used on portal frontpage?



sorry for the delay
with my mod, no. Not without more coding to the mod.  With SimplePortal, it may be possible to select a board to pull from.

moguns

Are you still around? This is a great mod. Can it be updated

madman71

#50
As i have mentioned already, this mod will not be updated (at least by me). it has served its purpose for me.  I have now moved on to using the random image attachment banner that is found in the simple portal modification.

There's so much more control of the attachment banner that is found in simple portal.

http://www.simpleportal.net/

moguns

I agree but I just use smf as it is intended not as a full site. Less is better with smf.

NiceCarvings

On the simple portal version it doesn't link to the thread where the image was posted, or does it?

madman71

Quote from: NiceCarvings on July 11, 2012, 09:52:24 PM
On the simple portal version it doesn't link to the thread where the image was posted, or does it?

it does:
http://simpleportal.net/index.php?topic=4118.0

Herrybraun

Thank you so much to post it. I really appreciate it.

Advertisement: