Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: ***Teh GodFather*** on January 23, 2008, 11:46:48 PM

Title: Image Thumbnail
Post by: ***Teh GodFather*** on January 23, 2008, 11:46:48 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=1067)



IMAGE THUMBNAIL v1.0
By Tomahawk



Introduction
Enables you use bbcode to post large images which will be preview with a link to full image using imgt bbcode

Installation
Installs automatically on Default theme and any theme without a custom Post.template.php

To manually install this modification on other themes;
- place the imgt.gif in the "Themes/{ThemeName}/images/bbc" for EVERY THEME.
- A single manual edit is required FOR EACH THEME with a custom Post.template.php

Open Themes/{themename}/Post.template.php, and FIND:

$context['bbc_tags'][] = array(
'flash' => array('code' => 'flash', 'before' => '[flash=200,200]', 'after' => '[/flash]', 'description' => $txt[433]),

ADD AFTER:

'imgt' => array('code' => 'imgt', 'before' => '[imgt]', 'after' => '[/imgt]'),


If you are still having trouble, I recommend the Modification Parser (http://modparser.dev.dansoftaustralia.net/) by Daniel 15

How Do I Use This Mod?
This bbcode tag is used like img tag, only this tag will not show full image, but only a preview.


[imgt]url_to_image[/imgt]


Support
Please use the modification thread for support with this modification.
(Please don't ask me to do the edits for you)

Changelog
1.0
o Initial release
Title: Re: Image Thumbnail
Post by: Sectomy on January 30, 2008, 08:56:02 AM
great work !

is it possible to make an Pop Up box for adding the Url ? like the "image Pop Up" mod ?


greets

secy
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on January 31, 2008, 02:35:51 AM
I will try to add it to next version of mod, but I'm a bit busy right now...
Title: Re: Image Thumbnail
Post by: myaicons on February 01, 2008, 08:10:11 PM
is there a screenshot or demo of this mod ?
Title: Re: Image Thumbnail
Post by: slackerpunk on February 03, 2008, 06:43:16 PM
will this add the bbcode button automatically or do you have to manually input [imgt][/imgt]
Title: Re: Image Thumbnail
Post by: Sectomy on February 04, 2008, 03:47:43 AM
theres a bbcode button (the big "T") and it adds the tag to your editor field....
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on February 04, 2008, 03:56:04 AM
It adds button on default theme, but you have to add it manually to other themes, check the readme file...
Title: Re: Image Thumbnail
Post by: goldenboy48 on February 07, 2008, 01:57:38 AM
The resized image looks very weird...Its not properly scaled...
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on February 07, 2008, 09:24:21 AM
It depends on source image...
Title: Re: Image Thumbnail
Post by: goldenboy48 on February 07, 2008, 08:09:31 PM
Quote from: ***Teh GodFather*** on February 07, 2008, 09:24:21 AM
It depends on source image...

The source image is a perfect high quality image.

http://www.cricinfo.com/db/PICTURES/CMS/86300/86338.jpg

I think it resizes the image to a perfect square...Please make it do like 30% of the original image or sth. :D
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on February 08, 2008, 02:15:25 PM
It resizes it to 100x90 px... I will try to add it to the next version, but I'm not so good with php...
Title: Re: Image Thumbnail
Post by: goldenboy48 on February 09, 2008, 06:41:23 PM
Quote from: ***Teh GodFather*** on February 08, 2008, 02:15:25 PM
It resizes it to 100x90 px... I will try to add it to the next version, but I'm not so good with php...

Oh ok! If you could take out the next version fast, that would be very appreciated. Take the help of the tech guys on this forum for the next version ;) :D
Title: Re: Image Thumbnail
Post by: goldenboy48 on February 09, 2008, 07:03:43 PM
Ok, I edited your mod to resize the height and width to 25%.

But I would like to wrap text around those images [I already have float mod] but I don't know how make it work?

Any help Tom or others?

Edit Got it! End result - http://eCric.net/smftest under "Recent Article"

Tom, If you would like me to share the edited mod package with you, please tell me. I'll give it you. :D

Btw, does anyone know how to use GD technology with this mod so that resized images are of good quality.

Thanks
Title: Re: Image Thumbnail
Post by: goldenboy48 on February 13, 2008, 03:52:44 AM
Btw, does anyone know how to use GD technology with this mod so that resized images are of good quality.

Any PHP pros know how to do this?
Title: Re: Image Thumbnail
Post by: 4b11l on March 03, 2008, 05:28:23 AM
Hello,

I just want to say that I absolutely love this mod along with karl's lightbox mod.

I was wandering if there is a way to automatically turn [img] tags into this tag, [imgt]. I've went and disabled the [img] tag completely and if someone was to manually post an [img] tag, is there a way to automatically turn it into your [imgt] tag? Thanks.
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on March 03, 2008, 09:10:43 AM
Well, you could just edit it directly in file Subs.php, find where [img] tag is and replace it with [imgt] and then just remove "t"...
Title: Re: Image Thumbnail
Post by: 4b11l on March 03, 2008, 01:55:40 PM
I tried that but all current [img] tags now look like ( ) with the image link inside. :-\
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on March 07, 2008, 11:33:35 AM
It is very simple... Justi find this in Subs.php

Find
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
array(
'tag' => 'img',
'type' => 'unparsed_content',
'content' => '<img src="$1" alt="" border="0" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


And replace
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),


with
'width' => array('optional' => true, 'value' => ' width="{your width}"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="{your height}"', 'match' => '(\d+)'),
Title: Re: Image Thumbnail
Post by: lvzifer on March 22, 2008, 10:57:52 AM
is this modification to make thumbnail bigger ? it's to small ?? if not how could I do that ?
Title: Re: Image Thumbnail
Post by: 4b11l on March 25, 2008, 02:26:36 AM
Thanks Teh Godfather, that worked perfectly.

Quote from: PanesarV on February 09, 2008, 07:03:43 PM

Edit Got it! End result - http://eCric.net/smftest under "Recent Article"


Bro, I am trying to figure this out too. Would you be able to help me out on the resize keeping the aspect ratio. Thanks.
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on March 25, 2008, 10:46:32 AM
Quote from: lvzifer on March 22, 2008, 10:57:52 AM
is this modification to make thumbnail bigger ? it's to small ?? if not how could I do that ?
This modification adds new BBC, it is not editing any options...

I'll try to edit mod in next few days to improve it and fix some errors whic I found...
Title: Re: Image Thumbnail
Post by: goldenboy48 on March 27, 2008, 11:46:09 PM
Ok guys,

To keep the aspect ratio of the image while resizing it, I did this change to the mod.

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
   <name>Image Thumbnail BBCode</name>
   <id>Tomahawk:Image_Thumbnail_BBCode</id>
   <version>1.0</version>
   <homepage>http://tomahawk.110mb.com</homepage>
   <file name="$sourcedir/Subs.php">
      <operation>
         <search position="before"><![CDATA[
         array(
            'tag' => 'white',
            'before' => '<span style="color: white;">',
            'after' => '</span>',
         ),
]]></search>
         <add><![CDATA[
         array(
            'tag' => 'imgt',
            'type' => 'unparsed_content',
            'content' => '<a href="$1" target="_blank"><img src="$1" width="25%" height="25%" border="0" /></a>',
            'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
            'disabled_content' => '($1)',
         ),
]]></add>
      </operation>
</file>

<file name="$themedir/Post.template.php">
   <operation>
      <search position="before"><![CDATA[
         'flash' => array('code' => 'flash', 'before' => 'http://',%20'after'%20=>%20'', 'description' => $txt[433]),
]]></search>
   <add><![CDATA[
         'imgt' => array('code' => 'imgt', 'before' => '[imgt]', 'after' => '[/imgt]'),
]]></add>
   </operation>
</file>
</modification>
Title: Re: Image Thumbnail
Post by: 4b11l on March 28, 2008, 12:02:56 AM
Quote from: PanesarV on March 27, 2008, 11:46:09 PM
Ok guys,

To keep the aspect ratio of the image while resizing it, I did this change to the mod.

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
   <name>Image Thumbnail BBCode</name>
   <id>Tomahawk:Image_Thumbnail_BBCode</id>
   <version>1.0</version>
   <homepage>http://tomahawk.110mb.com</homepage>
   <file name="$sourcedir/Subs.php">
      <operation>
         <search position="before"><![CDATA[
         array(
            'tag' => 'white',
            'before' => '<span style="color: white;">',
            'after' => '</span>',
         ),
]]></search>
         <add><![CDATA[
         array(
            'tag' => 'imgt',
            'type' => 'unparsed_content',
            'content' => '<a href="$1" target="_blank"><img src="$1" width="25%" height="25%" border="0" /></a>',
            'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
            'disabled_content' => '($1)',
         ),
]]></add>
      </operation>
</file>

<file name="$themedir/Post.template.php">
   <operation>
      <search position="before"><![CDATA[
         'flash' => array('code' => 'flash', 'before' => 'http://',%20'after'%20=>%20'', 'description' => $txt[433]),
]]></search>
   <add><![CDATA[
         'imgt' => array('code' => 'imgt', 'before' => '[imgt]', 'after' => '[/imgt]'),
]]></add>
   </operation>
</file>
</modification>

Thanks a lot bro, that worked wonderfully.
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on March 28, 2008, 07:38:36 AM
I'm trying to make this with gd... I had some poblems, but i think that i got solution, i'll test it when i get home...
Title: Re: Image Thumbnail
Post by: goldenboy48 on March 30, 2008, 09:42:57 PM
GD Function would be great. Thanks.
Title: Re: Image Thumbnail
Post by: Ikhsan4488 on May 01, 2008, 02:54:50 PM
can i use this mod for smf 1.1.5?
Title: Re: Image Thumbnail
Post by: Succubus Evaligan on May 10, 2008, 04:34:53 AM
Hi somebody can help me?
I have this mod and I want mix with this other mod.
http://custom.simplemachines.org/mods/index.php?mod=771

The problem is the Display.template file

<![CDATA[
<td colspan="2" class="smalltext" width="100%">';
if (!empty($message['attachment']))
{
echo' <div style="overflow: auto; width: 100%;" >
<fieldset>
<legend><b>', $txt['Attached_files'], '</b></legend>
';
//check if there are really images to show as thubmnails
$has_image = false;
$no_image = false;
foreach ($message['attachment'] as $attachment)
{
if ($attachment['is_image'])
$has_image = true;
if (!$attachment['is_image'])
$no_image = true;
//we know there is an image and a non-image. So we can exit
if ($no_image && $has_image)
break;
}

//show text for images
if ($has_image)
echo '<b>', $txt['Thumbnails'], ':</b><br />';

//show the images
foreach ($message['attachment'] as $attachment)
{
if ($attachment['is_image'])
{
if ($attachment['thumbnail']['has_thumb'])
{
echo '
                                    <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" rel="lightbox"><img                       src="', $attachment['thumbnail']['href'], '" alt=""                id="thumb_', $attachment['id'], '" border="0" /></a>';
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '"  target="_blank"><img style="margin:5px;" src="', $attachment['thumbnail']['href'], '" align="middle" alt="" id="thumb_', $attachment['id'], '" border="0" /></a>';
}
else
{
echo '
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '"  target="_blank"><img  src="' . $attachment['href'] . ';image"  align="middle" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" border="0" /></a>';
}
}
}

//show text for other attached files
if ($no_image && $has_image)
echo '<br /><br /><b>', $txt['Other_attached_files'], ':</b><br />';

//show other attached files
foreach ($message['attachment'] as $attachment)
{
if (!($attachment['is_image']))
{
echo '
<br /><a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" />&nbsp;' . $attachment['name'] . '</a> (', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />';
}
}

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

How I do that two mods working together at same time?
Title: Re: Image Thumbnail
Post by: RoRoo on May 28, 2008, 08:42:37 AM
I'm loving this mod to death...
But When I replace the IMG tags with the IMGT ones to make the default tags use IMGT functionality, it also resizes the images users place in their signature....

Is there a way around this??

TIA!!

Robert
Title: Re: Image Thumbnail
Post by: TGB on May 29, 2008, 03:58:20 AM
thanks, I seen this mod and got to thinking I could try making one and here is my first version.
http://custom.simplemachines.org/mods/index.php?mod=1220

im anxious to see what you guys say is wrong with it  ;)
Title: Re: Image Thumbnail
Post by: ***Teh GodFather*** on June 13, 2008, 01:41:27 PM
Quote from: RoRoo on May 28, 2008, 08:42:37 AM
I'm loving this mod to death...
But When I replace the IMG tags with the IMGT ones to make the default tags use IMGT functionality, it also resizes the images users place in their signature....

Is there a way around this??

TIA!!

Robert

I don't think that you can do this because you are replacing tags...
Title: Re: Image Thumbnail
Post by: 58tbird on July 12, 2008, 12:51:18 PM
Quote from: Ikhsan4488 on May 01, 2008, 02:54:50 PM
can i use this mod for smf 1.1.5?
I just installed it on 1.1.5 and it seems to work fine.  However, is there supposed to be a description of the function when you hover over the button?  If so, maybe that fails in 1.1.5 because nothing happens when I hover over the new button.
Title: Re: Error Log, and Image Thumbnail description
Post by: 58tbird on July 14, 2008, 10:53:55 PM
Hi!  Can anyone help me on this?  I'm getting this error message:

    8: Undefined index: description
    File: ...default/languages/Post.english.php (main sub template - eval?)
    Line: 982

I just installed the Thumbnail Image mod, so I imagine it has something to do with that.  What can I do about this error, and does it harm anything other than load up my Error Log?

Also, is there any way to add a description of the function when you hover over the button?
Title: Re: Image Thumbnail
Post by: 58tbird on July 15, 2008, 02:42:08 PM
In case anyone else needs this information...

I haven't gotten a response here, but I received some help on the 1.1.x board here (http://www.simplemachines.org/community/index.php?topic=249853.0).

The end result is that the mod works for the most part, but it seems to be missing some instructions to call up the description for the button.  So there's no description when you hover over the button, and I'm not sure but every time someone either uses the button or maybe simply logs in to your forum it generates an error in your error log.  I suppose if you don't get much traffic you could simply delete the errors every day or two but if you don't want to mess with that, don't install.

I like the mod, so I may keep it.  But it would be great if this little bug could be fixed though.
Title: Re: Image Thumbnail
Post by: 58tbird on July 15, 2008, 08:56:00 PM
See the following threads:
http://www.simplemachines.org/community/index.php?topic=249676.msg1619715#msg1619715 (http://www.simplemachines.org/community/index.php?topic=249676.msg1619715#msg1619715)
and the solution: http://www.simplemachines.org/community/index.php?topic=249853.msg1621812#msg1621812 (http://www.simplemachines.org/community/index.php?topic=249853.msg1621812#msg1621812)
Title: Re: Image Thumbnail
Post by: illmakeyouscream on July 08, 2009, 09:20:45 AM
Can I get some help on this with the image tag or something this is totally different then the other thumbnail topic right? has nothing to be done with attachments.