Safe SVG - Version 1.6.1

Version Description

  • Images will now use the size chosen when inserted into the page rather than default to 2000px everytime.
Download this release

Release Info

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

Code changes from version 1.6.0 to 1.6.1

Files changed (2) hide show
  1. readme.txt +4 -1
  2. safe-svg.php +18 -5
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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
- Stable tag: 1.6.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -39,6 +39,9 @@ Install through the WordPress directory or download, unzip and upload the files
39
 
40
  == Changelog ==
41
 
 
 
 
42
  = 1.6.0 =
43
  * Fairly big new feature - The library now allows `<use>` elements as long as they don't reference external files!
44
  * You can now also embed safe image types within the SVG and not have them stripped (PNG, GIF, JPG)
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
+ Stable tag: 1.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
39
 
40
  == Changelog ==
41
 
42
+ = 1.6.1 =
43
+ * Images will now use the size chosen when inserted into the page rather than default to 2000px everytime.
44
+
45
  = 1.6.0 =
46
  * Fairly big new feature - The library now allows `<use>` elements as long as they don't reference external files!
47
  * You can now also embed safe image types within the SVG and not have them stripped (PNG, GIF, JPG)
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.6.0
7
  Author: Daryll Doyle
8
  Author URI: http://enshrined.co.uk
9
  Text Domain: safe-svg
@@ -186,8 +186,8 @@ if ( ! class_exists( 'safe_svg' ) ) {
186
 
187
  foreach ( $possible_sizes as $size => $label ) {
188
  $sizes[ $size ] = array(
189
- 'height' => 2000,
190
- 'width' => 2000,
191
  'url' => $response['url'],
192
  'orientation' => 'portrait',
193
  );
@@ -264,8 +264,21 @@ if ( ! class_exists( 'safe_svg' ) ) {
264
  $mime = get_post_mime_type( $id );
265
 
266
  if ( 'image/svg+xml' === $mime ) {
267
- $html = str_replace( 'width="1" ', '', $html );
268
- $html = str_replace( 'height="1" ', '', $html );
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  }
270
 
271
  return $html;
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.6.1
7
  Author: Daryll Doyle
8
  Author URI: http://enshrined.co.uk
9
  Text Domain: safe-svg
186
 
187
  foreach ( $possible_sizes as $size => $label ) {
188
  $sizes[ $size ] = array(
189
+ 'height' => get_option( "{$size}_size_w", 2000 ),
190
+ 'width' => get_option( "{$size}_size_h", 2000 ),
191
  'url' => $response['url'],
192
  'orientation' => 'portrait',
193
  );
264
  $mime = get_post_mime_type( $id );
265
 
266
  if ( 'image/svg+xml' === $mime ) {
267
+ if( is_array( $size ) ) {
268
+ $width = $size[0];
269
+ $height = $size[1];
270
+ } else {
271
+ $width = get_option( "{$size}_size_w", false );
272
+ $height = get_option( "{$size}_size_h", false );
273
+ }
274
+
275
+ if( $height && $width ) {
276
+ $html = str_replace( 'width="1" ', sprintf( 'width="%s" ', $width ), $html );
277
+ $html = str_replace( 'height="1" ', sprintf( 'height="%s" ', $height ), $html );
278
+ } else {
279
+ $html = str_replace( 'width="1" ', '', $html );
280
+ $html = str_replace( 'height="1" ', '', $html );
281
+ }
282
  }
283
 
284
  return $html;