WordPress.org

Forums

Pinterest Pin It Button For Images
Bad Image URLs - bug fix (1 post)

  1. FolioVision
    Member
    Posted 1 year ago #

    Hi there,

    there was a problem with the plugin when using relative image sources and having the image displayed in a post/page two or more times.

    Example:
    there was <img src="/images/my-image.jpg" /> included in the post twice - the plugin replaced the relative source with absolute, but when the same image source was there 2 times, the output looked like this: <img src="http://mydomain.comhttp//mydomain.com/images/my-image.jpg" />

    Solution:
    function pibfi_Engine_normalize_image_paths needs to be updated in a following way:

    function pibfi_Engine_normalize_image_paths( $content ){
    	$matches = array();
    	preg_match_all('/<img(.*?)src=[\'"](.*?)[\'"](.*?)>/i', $content, $matches);
    
      <em>// addition 
    
      $matches[2] = array_unique($matches[2]);
    
      // end of addition</em>
    
      foreach($matches[2] as $match){
        if($match{0} == "/"){
    			$content = str_replace($match, get_bloginfo("siteurl") . $match, $content);
    		}
    	}
    	return $content;
    }

    Hope this helps.

    [ Signature moderated. ]
    http://wordpress.org/extend/plugins/pinterest-pin-it-button-for-images/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Pinterest Pin It Button For Images
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic