If in a post (let's say) there is a text like:

http://Бла-Бла.Ню/wp-content/uploads/2015/10/2015-10-06_12-19-311.jpg 

How to convert it into a picture automatically? Type:

 <img class="" width="250" height="250" alt="" src="http://Бла-Бла.Ню/wp-content/uploads/2015/10/2015-10-06_12-19-311.jpg"> 
  • Write your function that will take post_content, replace all found links with images, and then return the content with links already. But it is easier to search for plugins for this, I think these should be. - Moonvvell

1 answer 1

 function my_img_replaсe($content){ $regex = '~(?<!src=")(ht|f)tps?://[\w%#\~:;&=+,(.(png|jpg|jpeg|gif))/?-]+~is'; $replace = '<img src="\\0" class="" width="250" height="250" alt="">'; return print preg_replace($regex, $replace, $content); } add_filter('the_content', 'my_img_replaсe'); 
  • +1 Thanks, helped - Alexander