Title: Plugin pulling wrong path for 2x images
Last modified: August 21, 2016

---

# Plugin pulling wrong path for 2x images

 *  Resolved [markhood73](https://wordpress.org/support/users/markhood73/)
 * (@markhood73)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/plugin-pulling-wrong-path-for-2x-images/)
 * I suspect this is a local config mistake, but I cannot find it – I hope you can
   help. I’m running version 3.6 wordpress on my local computer for development,
   and so far everything has been good. Now I’m adding retina support, and found
   your great plugin.
 * The plugin is there, has re-built all the images fine and they’re in the right
   folders. I’ve checked your FAQ, tutorial, all the pages of support here, and 
   google….
 * I’m using HTML rewrite, with debug mode on; I see it’s trying to rewrite the 
   image paths, but it fails. From wp-retina=2x.log:
 * – The retina file ‘/Applications/MAMP/htdocs/**wordpress/wordpress**/wp-content/
   uploads/2013/06/Street-Art-Brighton-2-1024×682@2x.jpg’ cannot be found.
 * That’s not surprising since it’s adding an extra ‘wordpress’ to the path – it
   should be:
 * /Applications/MAMP/htdocs/wordpress/wp-content/uploads/2013/06/Street-Art-Brighton-
   2-1024×682@2x.jpg
 * The site address and wordpress address are both configured as ‘[http://localhost:8888/wordpress&#8217](http://localhost:8888/wordpress&#8217);
   and everything else is working fine.
 * Any ideas where it’s getting that extra word from? Is it me configuring something
   wrong in the back-end somewhere?
 * Many thanks,
 * Mark
 * [http://wordpress.org/plugins/wp-retina-2x/](http://wordpress.org/plugins/wp-retina-2x/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [markhood73](https://wordpress.org/support/users/markhood73/)
 * (@markhood73)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/plugin-pulling-wrong-path-for-2x-images/#post-4020690)
 * I didn’t mention, but I’m on version 1.4.2 of your plugin (last one I can see).
 * For now, I’ve worked around it with the following edits in wp-retina-2x.php (
   just on my local testing site):
 * Line 109:
 *     ```
       //was	$filepath = trailingslashit( ABSPATH ) . $img_pathinfo;
       		$filepath = '/Applications/MAMP/htdocs/' . $img_pathinfo;
       ```
   
 * Line 113:
 *     ```
       //was	$retina_pathinfo = ltrim( str_replace( ABSPATH, "", $potential_retina ), '/' );
       		$retina_pathinfo = ltrim( str_replace( 'Applications/MAMP/htdocs', "", $potential_retina ), '/' );
       ```
   
 * _[Please post code & markup between backticks or use the code button. Your posted
   code may now have been permanently damaged by the forum’s parser.]_
 * So it’s ABSPATH that’s wrong – which comes from siteurl (I believe) – but changing
   that breaks my entire site!
 * It works on the live site, so I suspect my local install is wrong in some way,
   hopefully this can help other folks who might see something odd?
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/plugin-pulling-wrong-path-for-2x-images/#post-4020858)
 * Hey Mark,
 * I am not sure what happens but ABSPATH could be defined wrongly, it happens…
 * By any chance, can you replace the wr2x_html_rewrite function with this one? 
   It might work better…
 *     ```
       function wr2x_html_rewrite( $buffer ) {
       	if ( !isset( $buffer ) || trim( $buffer ) === '' )
       		return $buffer;
       	$doc = new DOMDocument();
       	@$doc->loadHTML( $buffer ); // = ($doc->strictErrorChecking = false;)
       	$imageTags = $doc->getElementsByTagName('img');
       	foreach ( $imageTags as $tag ) {
       		$img_info = parse_url( $tag->getAttribute('src') );
       		$img_pathinfo = ltrim( $img_info['path'], '/' );
       		//$filepath = trailingslashit( ABSPATH ) . $img_pathinfo;
       		$filepath = site_url( $img_pathinfo );
       		$potential_retina = wr2x_get_retina( $filepath );
       		if ( $potential_retina != null ) {
       			wr2x_log( "Rewrite '{$filepath}' to '{$potential_retina}'." );
       			//$retina_pathinfo = ltrim( str_replace( ABSPATH, "", $potential_retina ), '/' );
       			$retina_pathinfo = ltrim( str_replace( site_url(), "", $potential_retina ), '/' );
       			$buffer = str_replace( $img_pathinfo, $retina_pathinfo, $buffer );
       		}
       	}
       	return $buffer;
       }
       ```
   
 * If it works, I will do it this way and avoid using ABSPATH.
 *  Thread Starter [markhood73](https://wordpress.org/support/users/markhood73/)
 * (@markhood73)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/plugin-pulling-wrong-path-for-2x-images/#post-4020862)
 * Sorry, I get the same error:
 * – The retina file ‘[http://mac-pro.local:8888/wordpress/wordpress/wp-content/uploads/2013/06/Street-Art-Brighton-2-300×200@2x.jpg&#8217](http://mac-pro.local:8888/wordpress/wordpress/wp-content/uploads/2013/06/Street-Art-Brighton-2-300×200@2x.jpg&#8217);
   cannot be found.
 * I wouldn’t worry about it – it works on my ‘live’ site without any changes, and
   if I’m the first to see it, I’m more than happy it’s my local test site being
   set up incorrectly.
 * I appreciate the efforts though, I suspect my ‘site_url’ is wrong, and it’s influencing
   everything that relies on it. If I change it, the site breaks but maybe I should
   look into that, since your plugin is clearly working OK otherwise 🙂
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/plugin-pulling-wrong-path-for-2x-images/#post-4020863)
 * Yes, there is somebody strange on your localhost 🙂 Maybe you can try to check
   what gives your phpinfo()… Could be a starting point?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Plugin pulling wrong path for 2x images’ is closed to new replies.

 * ![](https://ps.w.org/wp-retina-2x/assets/icon-256x256.png?rev=2597316)
 * [Perfect Images: Regenerate Thumbnails, Image Sizes, WebP & AVIF](https://wordpress.org/plugins/wp-retina-2x/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-retina-2x/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-retina-2x/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-retina-2x/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-retina-2x/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-retina-2x/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/plugin-pulling-wrong-path-for-2x-images/#post-4020863)
 * Status: resolved