Safe SVG - Version 1.9.0

Version Description

  • If an image is the correct ratio, allow skipping of the crop popup when setting header/logo images with SVGs.
Download this release

Release Info

Developer enshrined
Plugin Icon 128x128 Safe SVG
Version 1.9.0
Comparing to
See all releases

Code changes from version 1.8.1 to 1.9.0

Files changed (2) hide show
  1. readme.txt +5 -2
  2. safe-svg.php +13 -10
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: enshrined
3
  Donate link: https://wpsvg.com/
4
  Tags: svg, sanitize, upload, sanitise, security, svg upload, image, vector, file, graphic, media, mime
5
  Requires at least: 4.0
6
- Tested up to: 4.9.1
7
  Requires PHP: 5.6
8
- Stable tag: 1.8.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -62,6 +62,9 @@ They take one argument that must be returned. See below for examples:
62
 
63
  == Changelog ==
64
 
 
 
 
65
  = 1.8.1 =
66
  * Don't let errors break upload if uploading an empty file
67
  * Fix featured image display in Gutenberg. Props @hendridm :)
3
  Donate link: https://wpsvg.com/
4
  Tags: svg, sanitize, upload, sanitise, security, svg upload, image, vector, file, graphic, media, mime
5
  Requires at least: 4.0
6
+ Tested up to: 5.0.2
7
  Requires PHP: 5.6
8
+ Stable tag: 1.9.0
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.0 =
66
+ * If an image is the correct ratio, allow skipping of the crop popup when setting header/logo images with SVGs.
67
+
68
  = 1.8.1 =
69
  * Don't let errors break upload if uploading an empty file
70
  * Fix featured image display in Gutenberg. Props @hendridm :)
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.8.1
7
  Author: Daryll Doyle
8
  Author URI: http://enshrined.co.uk
9
  Text Domain: safe-svg
@@ -184,6 +184,9 @@ if ( ! class_exists( 'safe_svg' ) ) {
184
  public function fix_admin_preview( $response, $attachment, $meta ) {
185
 
186
  if ( $response['mime'] == 'image/svg+xml' ) {
 
 
 
187
  $possible_sizes = apply_filters( 'image_size_names_choose', array(
188
  'full' => __( 'Full Size' ),
189
  'thumbnail' => __( 'Thumbnail' ),
@@ -197,13 +200,9 @@ if ( ! class_exists( 'safe_svg' ) ) {
197
  $default_height = 2000;
198
  $default_width = 2000;
199
 
200
- if ( 'full' === $size ) {
201
- $dimensions = $this->svg_dimensions( get_attached_file( $attachment->ID ) );
202
-
203
- if ( $dimensions ) {
204
- $default_height = $dimensions['height'];
205
- $default_width = $dimensions['width'];
206
- }
207
  }
208
 
209
  $sizes[ $size ] = array(
@@ -386,7 +385,11 @@ if ( ! class_exists( 'safe_svg' ) ) {
386
  }
387
  }
388
 
389
- return array( 'width' => $width, 'height' => $height );
 
 
 
 
390
  }
391
 
392
  /**
@@ -420,4 +423,4 @@ if ( ! class_exists( 'safe_svg' ) ) {
420
  }
421
  }
422
 
423
- $safe_svg = new safe_svg();
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.0
7
  Author: Daryll Doyle
8
  Author URI: http://enshrined.co.uk
9
  Text Domain: safe-svg
184
  public function fix_admin_preview( $response, $attachment, $meta ) {
185
 
186
  if ( $response['mime'] == 'image/svg+xml' ) {
187
+ $dimensions = $this->svg_dimensions( get_attached_file( $attachment->ID ) );
188
+ $response = array_merge($response, $dimensions);
189
+
190
  $possible_sizes = apply_filters( 'image_size_names_choose', array(
191
  'full' => __( 'Full Size' ),
192
  'thumbnail' => __( 'Thumbnail' ),
200
  $default_height = 2000;
201
  $default_width = 2000;
202
 
203
+ if ( 'full' === $size && $dimensions ) {
204
+ $default_height = $dimensions['height'];
205
+ $default_width = $dimensions['width'];
 
 
 
 
206
  }
207
 
208
  $sizes[ $size ] = array(
385
  }
386
  }
387
 
388
+ return array(
389
+ 'width' => $width,
390
+ 'height' => $height,
391
+ 'orientation' => ($width > $height) ? 'landscape' : 'portrait'
392
+ );
393
  }
394
 
395
  /**
423
  }
424
  }
425
 
426
+ $safe_svg = new safe_svg();