Bug with method "HTML Rewrite" and fix
-
File: wp-retina-2x.php
Version: 1.2.0
Line: from 97$filepath = trailingslashit( $_SERVER['DOCUMENT_ROOT'] ) . $img_pathinfo; $potential_retina = wr2x_get_retina( $filepath ); if ( $potential_retina != null ) { $retina_pathinfo = ltrim( str_replace( $_SERVER['DOCUMENT_ROOT'], "", $potential_retina ), '/' ); $buffer = str_replace( $img_pathinfo, $retina_pathinfo, $buffer ); }
The code here only works for WP site that installed in root directory, if the plugin is installed to a WP site that in a sub directory, it will fail to find the 2x version of image because the $filepath is wrong, to get the right path, replace
$_SERVER['DOCUMENT_ROOT']
withABSPATH
which is set to the path of current site, so that the updated code:$filepath = trailingslashit( ABSPATH ) . $img_pathinfo; $potential_retina = wr2x_get_retina( $filepath ); if ( $potential_retina != null ) { $retina_pathinfo = ltrim( str_replace( ABSPATH, "", $potential_retina ), '/' ); $buffer = str_replace( $img_pathinfo, $retina_pathinfo, $buffer ); }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Bug with method "HTML Rewrite" and fix’ is closed to new replies.