SVG Support - Version 2.2.5

Version Description

  • FIX: Display SVG thumbnails in attachment modals.
Download this release

Release Info

Developer Benbodhi
Plugin Icon 128x128 SVG Support
Version 2.2.5
Comparing to
See all releases

Code changes from version 2.2.4 to 2.2.5

Files changed (3) hide show
  1. functions/attachment-modal.php +37 -0
  2. readme.txt +29 -5
  3. svg-support.php +3 -2
functions/attachment-modal.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Display SVG in attachment modal
4
+ */
5
+ function bodhi_svgs_response_for_svg( $response, $attachment, $meta ) {
6
+
7
+ if( $response['mime'] == 'image/svg+xml' && empty( $response['sizes'] ) ) {
8
+
9
+ $svg_path = get_attached_file( $attachment->ID );
10
+ $dimensions = bodhi_svgs_get_dimensions( $svg_path );
11
+
12
+ $response[ 'sizes' ] = array(
13
+ 'full' => array(
14
+ 'url' => $response[ 'url' ],
15
+ 'width' => $dimensions->width,
16
+ 'height' => $dimensions->height,
17
+ 'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait'
18
+ )
19
+ );
20
+
21
+ }
22
+
23
+ return $response;
24
+
25
+ }
26
+ add_filter( 'wp_prepare_attachment_for_js', 'bodhi_svgs_response_for_svg', 10, 3 );
27
+
28
+ function bodhi_svgs_get_dimensions( $svg ) {
29
+
30
+ $svg = simplexml_load_file( $svg );
31
+ $attributes = $svg->attributes();
32
+ $width = (string) $attributes->width;
33
+ $height = (string) $attributes->height;
34
+
35
+ return (object) array( 'width' => $width, 'height' => $height );
36
+
37
+ }
readme.txt CHANGED
@@ -3,12 +3,12 @@ Contributors: Benbodhi
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Z9R7JERS82EQQ
4
  Tags: svg, vector, css, style, mime, mime type, embed, img, inline
5
  Requires at least: 4.0
6
- Tested up to: 4.8-alpha-39894
7
- Stable tag: 2.2.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Allow SVG file uploads using the WordPress Media Library uploader plus direct styling of SVG elements using CSS.
12
 
13
  == Description ==
14
 
@@ -99,9 +99,25 @@ or
99
 
100
  == Frequently Asked Questions ==
101
 
102
- = Got a question? =
103
 
104
- I will put the answers to any questions asked here.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  == Screenshots ==
107
 
@@ -110,6 +126,10 @@ I will put the answers to any questions asked here.
110
 
111
  == Changelog ==
112
 
 
 
 
 
113
  = 2.2.4 =
114
 
115
  * FIX: Added function to temporarily fix an issue with uploading in WP 4.7.1
@@ -202,6 +222,10 @@ I will put the answers to any questions asked here.
202
 
203
  == Upgrade Notice ==
204
 
 
 
 
 
205
  = 2.2.4 =
206
 
207
  * IMPORTANT: Fixes upload ability in WP 4.7.1
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Z9R7JERS82EQQ
4
  Tags: svg, vector, css, style, mime, mime type, embed, img, inline
5
  Requires at least: 4.0
6
+ Tested up to: 4.8-alpha-39901
7
+ Stable tag: 2.2.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Allow SVG file uploads using the WordPress Media Library uploader plus direct styling/animation of SVG elements using CSS/JS.
12
 
13
  == Description ==
14
 
99
 
100
  == Frequently Asked Questions ==
101
 
102
+ = I'm trying to use SVG in the customizer but it's not working. =
103
 
104
+ To allow SVG to work in the customizer, you will need to modify/add some code in your child theme's function file. [Here is a great tutorial](https://thebrandid.com/using-svg-logos-wordpress-customizer/) on how to do that. The important part is
105
+ `
106
+ 'flex-width' => true
107
+ 'flex-height' => true
108
+ `
109
+
110
+ = How do I add animation to my SVG? =
111
+
112
+ You will need to edit your SVG file in a code editor so you can add CSS classes to each element you need to target within the SVG. Make sure that your IMG tag is being swapped out for your inline SVG and then you can use CSS or JS to apply animations to elements within your SVG file.
113
+
114
+ = Why is SVG Support not working in multisite? =
115
+
116
+ If you installed multisite prior to WordPress 3.5, then you will need to remove your ms-files. Here is a couple of resources to help you: [Dumping ms-files](http://halfelf.org/2012/dumping-ms-files/) [Removing ms-files after 3.5](https://www.yunomie.com/2298/removing-ms-files-php-after-upgrading-an-existing-multisite-installation-to-3-5/).
117
+
118
+ = Why is my SVG not working in Visual Composer? =
119
+
120
+ If you are using SVG Support with Visual Composer or any other page builders, you will need to make sure that you can add your own class to the image. The easiest way to do this is by using a simple text or code block in the builder to put your image code in to.
121
 
122
  == Screenshots ==
123
 
126
 
127
  == Changelog ==
128
 
129
+ = 2.2.5 =
130
+
131
+ * FIX: Display SVG thumbnails in attachment modals.
132
+
133
  = 2.2.4 =
134
 
135
  * FIX: Added function to temporarily fix an issue with uploading in WP 4.7.1
222
 
223
  == Upgrade Notice ==
224
 
225
+ = 2.2.5 =
226
+
227
+ * Fix to display SVG thumbnails in attachment modals. (NOTE: You can not edit SVG files like other images in WordPress)
228
+
229
  = 2.2.4 =
230
 
231
  * IMPORTANT: Fixes upload ability in WP 4.7.1
svg-support.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: SVG Support
4
  Plugin URI: http://wordpress.org/plugins/svg-support/
5
  Description: Allow SVG file uploads using the WordPress Media Library uploader plus direct styling of SVG elements using CSS.
6
- Version: 2.2.4
7
  Author: Benbodhi
8
  Author URI: http://benbodhi.com
9
  Text Domain: svg-support
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
35
  /********************************************
36
  * GLOBAL VARIABLES
37
  ********************************************/
38
- $svgs_plugin_version = '2.2.4'; // for use on admin pages
39
  $plugin_file = plugin_basename(__FILE__); // plugin file for reference
40
  define( 'BODHI_SVGS_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); // define the absolute plugin path for includes
41
  $bodhi_svgs_options = get_option('bodhi_svgs_settings'); // retrieve our plugin settings from the options table
@@ -47,6 +47,7 @@ include( BODHI_SVGS_PLUGIN_PATH . 'admin/admin-init.php' ); // initial
47
  include( BODHI_SVGS_PLUGIN_PATH . 'admin/plugin-action-meta-links.php' ); // add links to the plugin on the plugins page
48
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/mime-types.php' ); // setup mime types support for SVG
49
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/thumbnail-display.php' ); // make SVG thumbnails display correctly in media library
 
50
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/enqueue.php' ); // enqueue js & css for inline replacement & admin
51
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/localization.php' ); // setup localization & languages
52
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/attribute-control.php' ); // auto set SVG class & remove dimensions during insertion
3
  Plugin Name: SVG Support
4
  Plugin URI: http://wordpress.org/plugins/svg-support/
5
  Description: Allow SVG file uploads using the WordPress Media Library uploader plus direct styling of SVG elements using CSS.
6
+ Version: 2.2.5
7
  Author: Benbodhi
8
  Author URI: http://benbodhi.com
9
  Text Domain: svg-support
35
  /********************************************
36
  * GLOBAL VARIABLES
37
  ********************************************/
38
+ $svgs_plugin_version = '2.2.5'; // for use on admin pages
39
  $plugin_file = plugin_basename(__FILE__); // plugin file for reference
40
  define( 'BODHI_SVGS_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); // define the absolute plugin path for includes
41
  $bodhi_svgs_options = get_option('bodhi_svgs_settings'); // retrieve our plugin settings from the options table
47
  include( BODHI_SVGS_PLUGIN_PATH . 'admin/plugin-action-meta-links.php' ); // add links to the plugin on the plugins page
48
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/mime-types.php' ); // setup mime types support for SVG
49
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/thumbnail-display.php' ); // make SVG thumbnails display correctly in media library
50
+ include( BODHI_SVGS_PLUGIN_PATH . 'functions/attachment-modal.php' ); // make SVG thumbnails display correctly in attachment modals
51
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/enqueue.php' ); // enqueue js & css for inline replacement & admin
52
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/localization.php' ); // setup localization & languages
53
  include( BODHI_SVGS_PLUGIN_PATH . 'functions/attribute-control.php' ); // auto set SVG class & remove dimensions during insertion