| @@ -70,8 +70,18 @@ | ||
| 70 | 70 | $path_data['path'] |
| 71 | 71 | ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | + public function file_exists( string $image_size ): bool { | |
| 75 | + $path = $this->get_file_path( $image_size ); | |
| 76 | + | |
| 77 | + if ( ! $path ) { | |
| 78 | + return false; | |
| 79 | + } | |
| 80 | + | |
| 81 | + return file_exists( $path ); | |
| 82 | + } | |
| 83 | + | |
| 74 | 84 | /** |
| 75 | 85 | * Returns true if an image marked as optimized. |
| 76 | 86 | * |
| 77 | 87 | * @return bool |
| @@ -177,12 +187,12 @@ | ||
| 177 | 187 | $this->image_id = $image_id; |
| 178 | 188 | $this->attachment_object = get_post( $image_id ); |
| 179 | 189 | |
| 180 | 190 | if ( ! $this->attachment_object ) { |
| 181 | - throw new Invalid_Image_Exception( "There is no entity with id '$image_id'" ); | |
| 191 | + throw new Invalid_Image_Exception( esc_html( "There is no entity with id '$image_id'" ) ); | |
| 182 | 192 | } |
| 183 | 193 | |
| 184 | 194 | if ( ! wp_attachment_is_image( $this->attachment_object ) ) { |
| 185 | - throw new Invalid_Image_Exception( "Post '$image_id' is not an image" ); | |
| 195 | + throw new Invalid_Image_Exception( esc_html( "Post '$image_id' is not an image" ) ); | |
| 186 | 196 | } |
| 187 | 197 | } |
| 188 | 198 | } |