Skip to content
Snippets Groups Projects
Commit 34329111 authored by Kevin Langley's avatar Kevin Langley
Browse files

checking if file_exists before attempting to get image size

parent 48ed24d4
Branches
Tags
No related merge requests found
...@@ -204,6 +204,8 @@ if( !class_exists( 'CDN_Rewrite' ) ){ ...@@ -204,6 +204,8 @@ if( !class_exists( 'CDN_Rewrite' ) ){
} }
private function get_version($url) { private function get_version($url) {
$version = false;
if(0 === strpos($url, $this->root_url)) { if(0 === strpos($url, $this->root_url)) {
$parts = parse_url($url); $parts = parse_url($url);
foreach( array( 'scheme', 'host', 'path' ) as $part ){ foreach( array( 'scheme', 'host', 'path' ) as $part ){
...@@ -212,12 +214,12 @@ if( !class_exists( 'CDN_Rewrite' ) ){ ...@@ -212,12 +214,12 @@ if( !class_exists( 'CDN_Rewrite' ) ){
} }
$file_path = str_replace( site_url('/'), ABSPATH, $parts['scheme'] . '://' . $parts['host'] . $parts['path'] ); $file_path = str_replace( site_url('/'), ABSPATH, $parts['scheme'] . '://' . $parts['host'] . $parts['path'] );
if( !($version = @filemtime($file_path)) ) {
if( file_exists( $file_path ) && !($version = @filemtime($file_path)) ) {
$version = $this->default_version; $version = $this->default_version;
} }
return $version;
} }
return false; return $version;
} }
public function replace_version($src) { public function replace_version($src) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment