Customizing SMF > Tips and Tricks

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

<< < (5/5)

Liam_michael:

--- Quote from: Kermit on June 12, 2012, 11:58:02 AM ---
--- Quote from: Liam_michael on June 11, 2012, 10:47:51 PM ---Is there a way to automatically have the [ img ] and [/ img] inserted between an image link?

--- End quote ---

What for ? If images would be shown without insterting those tags in the post

--- End quote ---

Because if I don't add [ img ] to the link, it won't obey the settings in the admin section that asks how large a picture can be. I've set mine to 350 px.

Liam_michael:

--- Quote from: Liam_michael on June 23, 2012, 11:14:21 AM ---Can anyone else assist me here? :-[

--- End quote ---

Bump...

Guy Verschuere:
Nice trick!

But: I notice that this one breaks all old topics as it is used for every view. Topics with picture with IMG tags are also processed.
Is there a way to have this trick in /Sources/Post.php?

rallepralle:

--- Quote from: Kermit on July 11, 2010, 05:07:13 AM ---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 ---

--- End quote ---

What does 'img src="$1$2"' mean? I want to understand what it means because I modify the code so it can also display videos without adding a tag to the link.

Navigation

[0] Message Index

[*] Previous page

Go to full version