Is there a way (perhaps in functions.php) to have any inmages added to post with the image uploader have target="_blank" added to the path.
I can do it after adding the image by clicking on "link" but I seem to forget to do that most of the time. It would be better (for me) if it was auto as part of the a href=
Hi,
Try with this function:
$(document).ready(function() {
$("a[@href^=http]").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
}})
});
Thanks,
Shane G.
Hi Shane,
I added this,
/**
* Add target new to images in posts.
*/
function $(document).ready(function() {
$("a[@href^=http]").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('target', '_blank');
}})
});
to function.php and my site would not open.