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
Quote from: Delita Heiral on July 11, 2010, 02:44:22 PM
Quote from: DoctorMalboro on July 11, 2010, 02:27:46 PM
Quote from: Duncan85 on July 11, 2010, 12:45:12 PMQuote from: DoctorMalboro on July 11, 2010, 12:13:41 PMIsn't that a mod? ::)
Is it ? ^^
Isn't this the same function that AeMe has? or i'm just crazy? :P
I don't think AeMe embed images in a post...
Nope it doesn't...
Duncan85 is there a way to disable (not to show) it?
[noembed][/noembed]
won't do
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?
Quote from: Delita Heiral on July 13, 2010, 10:53:01 AM
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
Quote from: Duncan85 on July 13, 2010, 12:02:32 PM
Quote from: Delita Heiral on July 13, 2010, 10:53:01 AM
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
Quote from: devoetbalkantine on March 03, 2011, 11:00:52 AM
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?
Quote from: devoetbalkantine on March 19, 2011, 07:01:28 PM
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?
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?
What for ? If images would be shown without insterting those tags in the post
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?
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?
Quote from: Kermit on July 11, 2010, 05:07:13 AM
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.