Version Description
- Fixed a warning about an Illegal string offset
- Fixed an issue if something other than a WP_Post object is passed in via the
wp_get_attachment_image_attributesfilter.
Download this release
Release Info
| Developer | enshrined |
| Plugin | |
| Version | 1.9.2 |
| Comparing to | |
| See all releases | |
Code changes from version 1.9.1 to 1.9.2
- readme.txt +5 -1
- safe-svg.php +58 -3
readme.txt
CHANGED
|
@@ -5,7 +5,7 @@ Tags: svg, sanitize, upload, sanitise, security, svg upload, image, vector, file
|
|
| 5 |
Requires at least: 4.0
|
| 6 |
Tested up to: 5.0.2
|
| 7 |
Requires PHP: 5.6
|
| 8 |
-
Stable tag: 1.9.
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
|
@@ -62,6 +62,10 @@ They take one argument that must be returned. See below for examples:
|
|
| 62 |
|
| 63 |
== Changelog ==
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
= 1.9.1 =
|
| 66 |
* Fixed a warning that was being generated by a change made in 1.9.0.
|
| 67 |
|
| 5 |
Requires at least: 4.0
|
| 6 |
Tested up to: 5.0.2
|
| 7 |
Requires PHP: 5.6
|
| 8 |
+
Stable tag: 1.9.2
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
| 62 |
|
| 63 |
== Changelog ==
|
| 64 |
|
| 65 |
+
= 1.9.2 =
|
| 66 |
+
* Fixed a warning about an Illegal string offset
|
| 67 |
+
* Fixed an issue if something other than a WP_Post object is passed in via the `wp_get_attachment_image_attributes` filter.
|
| 68 |
+
|
| 69 |
= 1.9.1 =
|
| 70 |
* Fixed a warning that was being generated by a change made in 1.9.0.
|
| 71 |
|
safe-svg.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Safe SVG
|
| 4 |
Plugin URI: https://wpsvg.com/
|
| 5 |
Description: Allows SVG uploads into WordPress and sanitizes the SVG before saving it
|
| 6 |
-
Version: 1.9.
|
| 7 |
Author: Daryll Doyle
|
| 8 |
Author URI: http://enshrined.co.uk
|
| 9 |
Text Domain: safe-svg
|
|
@@ -321,8 +321,56 @@ if ( ! class_exists( 'safe_svg' ) ) {
|
|
| 321 |
* @return mixed Metadata for attachment.
|
| 322 |
*/
|
| 323 |
function skip_svg_regeneration( $metadata, $attachment_id ) {
|
| 324 |
-
|
| 325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
}
|
| 327 |
|
| 328 |
return $metadata;
|
|
@@ -404,6 +452,13 @@ if ( ! class_exists( 'safe_svg' ) ) {
|
|
| 404 |
* (in that order). Default 'thumbnail'.
|
| 405 |
*/
|
| 406 |
public function fix_direct_image_output( $attr, $attachment, $size ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
$mime = get_post_mime_type( $attachment->ID );
|
| 408 |
if ( 'image/svg+xml' === $mime ) {
|
| 409 |
$default_height = 100;
|
| 3 |
Plugin Name: Safe SVG
|
| 4 |
Plugin URI: https://wpsvg.com/
|
| 5 |
Description: Allows SVG uploads into WordPress and sanitizes the SVG before saving it
|
| 6 |
+
Version: 1.9.2
|
| 7 |
Author: Daryll Doyle
|
| 8 |
Author URI: http://enshrined.co.uk
|
| 9 |
Text Domain: safe-svg
|
| 321 |
* @return mixed Metadata for attachment.
|
| 322 |
*/
|
| 323 |
function skip_svg_regeneration( $metadata, $attachment_id ) {
|
| 324 |
+
$mime = get_post_mime_type( $attachment_id );
|
| 325 |
+
if ( 'image/svg+xml' === $mime ) {
|
| 326 |
+
$additional_image_sizes = wp_get_additional_image_sizes();
|
| 327 |
+
$svg_path = get_attached_file( $attachment_id );
|
| 328 |
+
$upload_dir = wp_upload_dir();
|
| 329 |
+
// get the path relative to /uploads/ - found no better way:
|
| 330 |
+
$relative_path = str_replace( $upload_dir['basedir'], '', $svg_path );
|
| 331 |
+
$filename = basename( $svg_path );
|
| 332 |
+
|
| 333 |
+
$dimensions = $this->svg_dimensions( $svg_path );
|
| 334 |
+
|
| 335 |
+
$metadata = array(
|
| 336 |
+
'width' => intval( $dimensions->width ),
|
| 337 |
+
'height' => intval( $dimensions->height ),
|
| 338 |
+
'file' => $relative_path
|
| 339 |
+
);
|
| 340 |
+
|
| 341 |
+
// Might come handy to create the sizes array too - But it's not needed for this workaround! Always links to original svg-file => Hey, it's a vector graphic! ;)
|
| 342 |
+
$sizes = array();
|
| 343 |
+
foreach ( get_intermediate_image_sizes() as $s ) {
|
| 344 |
+
$sizes[ $s ] = array( 'width' => '', 'height' => '', 'crop' => false );
|
| 345 |
+
|
| 346 |
+
if ( isset( $additional_image_sizes[ $s ]['width'] ) ) {
|
| 347 |
+
// For theme-added sizes
|
| 348 |
+
$sizes[ $s ]['width'] = intval( $additional_image_sizes[ $s ]['width'] );
|
| 349 |
+
} else {
|
| 350 |
+
// For default sizes set in options
|
| 351 |
+
$sizes[ $s ]['width'] = get_option( "{$s}_size_w" );
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
if ( isset( $additional_image_sizes[ $s ]['height'] ) ) {
|
| 355 |
+
// For theme-added sizes
|
| 356 |
+
$sizes[ $s ]['height'] = intval( $additional_image_sizes[ $s ]['height'] );
|
| 357 |
+
} else {
|
| 358 |
+
// For default sizes set in options
|
| 359 |
+
$sizes[ $s ]['height'] = get_option( "{$s}_size_h" );
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
if ( isset( $additional_image_sizes[ $s ]['crop'] ) ) {
|
| 363 |
+
// For theme-added sizes
|
| 364 |
+
$sizes[ $s ]['crop'] = intval( $additional_image_sizes[ $s ]['crop'] );
|
| 365 |
+
} else {
|
| 366 |
+
// For default sizes set in options
|
| 367 |
+
$sizes[ $s ]['crop'] = get_option( "{$s}_crop" );
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
$sizes[ $s ]['file'] = $filename;
|
| 371 |
+
$sizes[ $s ]['mime-type'] = $mime;
|
| 372 |
+
}
|
| 373 |
+
$metadata['sizes'] = $sizes;
|
| 374 |
}
|
| 375 |
|
| 376 |
return $metadata;
|
| 452 |
* (in that order). Default 'thumbnail'.
|
| 453 |
*/
|
| 454 |
public function fix_direct_image_output( $attr, $attachment, $size ) {
|
| 455 |
+
|
| 456 |
+
// If we're not getting a WP_Post object, bail early.
|
| 457 |
+
// @see https://wordpress.org/support/topic/notice-trying-to-get-property-id/
|
| 458 |
+
if ( ! $attachment instanceof WP_Post ) {
|
| 459 |
+
return $attr;
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
$mime = get_post_mime_type( $attachment->ID );
|
| 463 |
if ( 'image/svg+xml' === $mime ) {
|
| 464 |
$default_height = 100;
|
