Customizing SMF > Tips and Tricks

Auto-show image links as pictures without using [img] tag in messages

(1/5) > >>

Kermit:
This little trick would show up the image links without inserting image links between the img tags

Demo:

http://i28.tinypic.com/xdih5k.jpg

./Sources/Subs.php


--- Code: (find) --- if (substr($message, 0, 1) == ' ')
$message = ' ' . substr($message, 1);

--- End code ---


--- Code: (replace) --- if (substr($message, 0, 1) == ' ')
$message = ' ' . substr($message, 1);
             
if (strpos($message, '<a href') !== false && !strpos($message ,'quote'))
{
    //show up images without inserting them between [img] tags ;)
$message = preg_replace('~<a href="(.*?)(\.(?i)(jpg|jpeg|gif|png|bmp))"(.*?)>(.*?)(\.(?i)(jpg|jpeg|gif|png|bmp))</a>~i', '<img src="$1$2" alt="" />', $message);
}

--- End code ---

For nCode Image Resizer Mod users,they need to replace with this one


--- Code: (replace) --- if (substr($message, 0, 1) == ' ')
$message = '&nbsp;' . substr($message, 1);

if (strpos($message, '<a href') !== false && !strpos($message ,'quote'))
{
   //show up images without inserting them between [img] tags ;)
$message = preg_replace('~<a href="(.*?)(\.(?i)(jpg|jpeg|gif|png|bmp))"(.*?)>(.*?)(\.(?i)(jpg|jpeg|gif|png|bmp))</a>~i', '<img src="$1$2" alt="" onload="NcodeImageResizer.createOn(this);"/>', $message);
}
--- End code ---

Jokerâ„¢:
Really cool trick , gonna use it soon   ;D .

in demo it's me , how cool  8)

DoctorMalboro:
Isn't that a mod? ::)

Nice trick! :P

Kermit:

--- Quote from: DoctorMalboro on July 11, 2010, 12:13:41 PM ---Isn't that a mod? ::)

--- End quote ---

Is it ? ^^

DoctorMalboro:

--- Quote from: Duncan85 on July 11, 2010, 12:45:12 PM ---
--- Quote from: DoctorMalboro on July 11, 2010, 12:13:41 PM ---Isn't that a mod? ::)
--- End quote ---
Is it ? ^^
--- End quote ---
Isn't this the same function that AeMe has? or i'm just crazy? :P

Navigation

[0] Message Index

[#] Next page

Go to full version