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
if (substr($message, 0, 1) == ' ')
$message = ' ' . substr($message, 1);
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);
}
For nCode Image Resizer Mod (http://custom.simplemachines.org/mods/index.php?mod=1197) users,they need to replace with this one
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="" onload="NcodeImageResizer.createOn(this);"/>', $message);
}
Really cool trick , gonna use it soon ;D .
in demo it's me , how cool 8)
Isn't that a mod? ::)
Nice trick! :P
You mean not to show the images ? Then just not change the codes like i gave above O:)
or maybe you want to make it like ,when there is an image link in message,it should be shown as like
Image (http://blabla.image.jpg)
If yes,you can do this
if (substr($message, 0, 1) == ' ')
$message = ' ' . substr($message, 1);
if (strpos($message, '<a href') !== false )
{
//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', '<a href="$1$2">Image</a> ', $message);
}
Let's say it auto show the images, great, but what if some user rather not show but a normal link if they so decide?
Zitat von: Delita Heiral in Juli 13, 2010, 10:53:01 VORMITTAG
Let's say it auto show the images, great, but what if some user rather not show but a normal link if they so decide?
It's a thing which would demand kinda long work,as this is just a little trick,i would rather not do it here,if you want ,you can create a topic in mod request board
Zitat von: Duncan85 in Juli 13, 2010, 12:02:32 NACHMITTAGS
Zitat von: Delita Heiral in Juli 13, 2010, 10:53:01 VORMITTAG
Let's say it auto show the images, great, but what if some user rather not show but a normal link if they so decide?
It's a thing which would demand kinda long work,as this is just a little trick,i would rather not do it here,if you want ,you can create a topic in mod request board
That's allright. 8)
Thanks for sharing with the community. :)
I have a question... This is working perfectly with 1 minor problem...
When a picture is posted without using the img-tags and the message also has a quote-tags in it, the picture doesn't show.
Just to be clear: The image is NOT in the quote but above it
Zitat von: devoetbalkantine in März 03, 2011, 11:00:52 VORMITTAG
I have a question... This is working perfectly with 1 minor problem...
When a picture is posted without using the img-tags and the message also has a quote-tags in it, the picture doesn't show.
Just to be clear: The image is NOT in the quote but above it
I think it's because of this line
if (strpos($message, '<a href') !== false && !strpos($message ,'quote'))you can try to replace this with this
if (strpos($message, '<a href') !== false)I didn't try it by myself,but i think it might work
In which file is that?
Zitat von: devoetbalkantine in März 19, 2011, 07:01:28 NACHMITTAGS
In which file is that?
The file is written already in the first message ;)
Ai... Guess I had my blonde moment
This is a good one. Especially for my gallery site. Thnx.
Any way to make this play nicely with http://custom.simplemachines.org/mods/index.php?mod=195
Is there a way to automatically have the [ img ] and [/ img] inserted between an image link?
Zitat von: Liam_michael in Juni 11, 2012, 10:47:51 NACHMITTAGS
Is there a way to automatically have the [ img ] and [/ img] inserted between an image link?
What for ? If images would be shown without insterting those tags in the post
Zitat von: Kermit in Juni 12, 2012, 11:58:02 VORMITTAG
Zitat von: Liam_michael in Juni 11, 2012, 10:47:51 NACHMITTAGS
Is there a way to automatically have the [ img ] and [/ img] inserted between an image link?
What for ? If images would be shown without insterting those tags in the post
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.
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?
Zitat von: Kermit in Juli 11, 2010, 05:07:13 VORMITTAG
For nCode Image Resizer Mod (http://custom.simplemachines.org/mods/index.php?mod=1197) users,they need to replace with this one
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="" onload="NcodeImageResizer.createOn(this);"/>', $message);
}
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.