If, like me, you have blogs where you use to have an image at the very beginning of your posts then you should know that people expect to access your post by clicking on the image (I tested this with CrazyEgg).
That’s why I came up with the Linked Image plugin. This little plugin does just that, it takes the first image in your post and links it to the post itself. Everywhere but in the post page.
Download
Installation
- Download the plugin and expand it.
- Copy the ‘first-image-permalink.php’ file into your plugins folder (wp-content/plugins/).
- Login into the WordPress administration area and go to the Plugins page.
- Locate the First Image Permalink plugin and click on the activate link
- That’s it
Known Issues
- The plugin doesn’t currently work if the first image is already linked and may render unexpected results.
- Smileys get linked too
Donate
Support further plugin development by making a small donation:
Thanks a lot for this pluging. Just downloaded, go to see how it works
cool plugin
it worked for me
thanks a lot
You’re very welcome. Please do not hesitate to contact me if you have any problem at all.
hello man
i need my link open in new windown,an ur teacher me to setup it??
@asian beauty talk: If you’re able to edit the plugin file (linked-image.php) then all you have to do is locate the part that says <a href=”‘.get_permalink().'”>$1</a> and change it for <a target=”_blank” href=”‘.get_permalink().'”>$1</a>
Excellent, tks Wessley, works out of the box!
does it works for older posts too?? Or it will work only for new posts??
@Khamosh: Yes, it’ll work for older posts as well.
Only one question…
If I add the image to the post trought the image uploader on WP2.5+, can the plugin retrieve the thumbnail of the image generated by the image uploader instead the image itself?
I wanted to do this long time ago, and I don´t know that if this plugin capable of this.
Downloading. Giving it a try. A very useful plugins if it works for me 😉
[…] kann dies WP nicht, doch mit diesem Plugin – Linked Image , von Wessley Roche – geht es, wenn das 1. Bild kein Link zum großen Bild […]
Great plugin.
Awesome idea and great plugin! Thank you very much!
Nice and simple.. Would make sense to implement the filter in “the_excerpt”, too. I’ve also the one problem that smiley-pictures are linked.. To avoid this you have to put something like this in the “if”:
$content1 = preg_replace($searchfor, $replacewith, $content, 1);
$smiley = substr_count($content1, ‘wp-smiley’);
if (!$smiley) $content = $content1;
Sorry, my code sucked 😉 But when you replace the $smiley-line with
preg_match ($searchfor , $content , $smileys);
$smiley = substr_count($smileys[0], ‘wp-smiley’);
it should work.. though I guess there are better ways to do this 😉
@Andy: You’re right… I didn’t realize smileys would get linked as well. Thanks for the suggestions, I’ll try to fix this asap.
hi. Thanks for plugin
perfect.
regards
can u pls tell me the coding if i want to make first three images as the permalink of the article …
thnx for a wonderful plugin
@Jaspal Singh: You would replace the “1” in this line: “$content = preg_replace($searchfor, $replacewith, $content, 1);” for a 3. Like: “$content = preg_replace($searchfor, $replacewith, $content, 3);”
[…] Linked Image- This plugin takes the first image in your post and links it to the post […]
[…] 3. Linked Image […]
[…] Linked Image : pour lier la première image de votre billet au post complet […]
Excellent idea. Do you or anybody know if it conflicts with this plugin from Justin Tadlock? –
http://justintadlock.com/archives/2008/05/27/get-the-image-wordpress-plugin
this is pretty cool. Btw, can it also capture the post title to be the image caption and alt tag?
Thanks and hope to see more improvement.
@gofree: It could. Definitely something to consider for a future version.
[…] Linked Image downloaden […]
Thanks so much for this. Just spent an hour mucking around with another plugin and this one worked instantly.
Dude, I love the way your comments look. Mind sharing the css and comments.php file to get it that way?
You are absolutely right! Images always have a visual attraction than the textual matter.
Very nice plugin that helped me alot!
Question: How can I change the Code to exclude certain categories of the function “wpguy_linked_image”?
Greetings from Switzerland
Hi
Just found the right Code to fix what I asked in the question above:
I changed “if (is_single() === FALSE)” into “if (is_single() === FALSE && in_category(7) === FALSE)” — so, if a post is from category ‘7’, the linkwrap does not appear.
Greetings from Switzerland
[…] View it here | Download 22) Linked Image- This plugin takes the first image in your post and links it to the post […]
Thanks for the plugin. Great Idea. I can’t believe wordpress does not have this as an option by default.
If an image is already linked this plugin causes 2 links to wrap the image, which can cause issues in different browsers. I’ve added a simple check to see if the image is already wrapped in an anchor tag, and if so the plugin will not add the permalink. Granted, its not the perfect solution but its a start.
function wpguy_linked_image($content){
$searchfor = ‘/(]*/>)/’;
if(preg_match($searchfor,$content)===1) {
$searchforLink = ‘/(]*/></a)/’;
if(preg_match($searchforLink,$content)===0) {
$replacewith = ‘$1‘;
if (is_single() === FALSE){
$content = preg_replace($searchfor, $replacewith, $content, 1);
}
}
}
return $content;
}
You could also use strpos() to check to see if ‘<img’ <=8 in the content, but theres a little more room for error there 😉
err… yeah.. comments parsed the code strangely.. don’t copy and past the above! But I think you get the idea.
In there any way of excluding certain images? I use the Add to Any plugin and the image turns into a link to my article if it’s within the threshold, instead of opening the Add to Any menu.
YAY! I’ve tested 5 plugins of the same functionality, but neither worked for me except yours!
Thanks a lot!
Doesn’t work without flaws on 2.6.2 WP
here’s the error on the single.php page
Fatal error: Call to undefined function similar_posts() in C:InetpubwwwrootExhd.comwp-contentthemesflexaircustomsingle.php on line 46
False Alarm it works , I forgot to have my other plugin activated (Similar posts)
Thank you so much for this Plugin. WordPress should have this as default.
Thanks
Elegant and simple. That’s exactly how any good blog should work (especially a recipe blog). I’ve had it set to always link to href=”” which would essentially just refresh the page which is fine on the page itself but annoying on the index if you want to get to the actual post. Thanks for a great plugin, works like a charm!
Thank you, Thank you, Thank you!!!! Exactly what I was looking for and works perfectly!! Thank you, Thank you, Thank you!!!!
Hi,
I’ve set a higher threshold, which works fine for me on all pages except my forums http://www.ps3bloggen.se/forum where the register and login buttons link to the forum page instead of their respective links.
So is there any way of excluding an entire URL and undercategory, like everything under http://www.ps3bloggen.se/forum?
Doesn’t work without flaws on 2.6.2 WP
here’s the error on the single.php page
Fatal error: Call to undefined function similar_posts() in C:InetpubwwwrootExhd.comwp-contentthemesflexaircustomsingle.php on line 46
Thanks for a great plugin, works like a charm!
Hello there wpguy! I think this is a great plugin but nothing happens on my site. Can you help me if you can? the link is http://www.colorblind.ro/test .
Cheers and thank you!
[…] -> Download […]
[…] How can I do that? I’ve tried with everything I have found on the internet, including the wpguy linked image plugin . Oh… And when I upload photos it formes a . Please help me if you can. The link to the site […]
Thanks very good plugin. Perfect working.
A thoughtful plugin and something a lot people should have.
thanks for posting great post
can you update plugin, i see no update for long time
[…] Linked Image- This plugin takes the first image in your post and links it to the post […]
[…] 22) Linked Image- This plugin takes the first image in your post and links it to the post itself. […]
[…] Source: […]
Do you know how I can filter out pages from this plugin? I’m having to put a header banner because things like an rss image will get linked too. I haven’t worked out in the code how to edit it so that it only works for pages. Do you know anything?!
To filter out pages from this plugin, just add !is_page() inside the if conditional statement.
if (!is_single() && !is_page()){
$content = preg_replace($searchfor, $replacewith, $content, 1);
}
Dude, you made it. Thank you very much.
Good stuff
Is there a way to make this plugin remove the original link instead of just wrapping it in a new?
Amazing plugin!!!
It still works, great!
Thanks for share. It’s very good!
It’s very good! However, How it creates links to old posts?
Thanks for the plugin. There is a little problem, it doesn’t work on categories, tags.
Can you please help. This is a great plugin.
Comments are closed.