Skip to content

Commit

Permalink
🐛 Fix duplicate width height attribute for SVG images
Browse files Browse the repository at this point in the history
  • Loading branch information
daomapsieucap committed May 13, 2022
1 parent ee7c502 commit 6339bcf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 35 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
== Changelog ==

= 2.0.6 =
*Release Date - 13 May 2022*

* Fixed: Fix duplicate width height attribute for SVG images.

= 2.0.5 =
*Release Date - 27 April 2022*

Expand Down
4 changes: 2 additions & 2 deletions fiberadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Fiber Admin
* Plugin URI: https://wordpress.org/plugins/fiber-admin/
* Description: 💈 Bring multiple customization features to make your own WordPress admin.
* Version: 2.0.5
* Version: 2.0.6
* Requires at least: 5.2
* Requires PHP: 7.0
* Author: Dao
Expand All @@ -25,7 +25,7 @@
* Definitions
*/

const FIBERADMIN_VERSION = '2.0.5';
const FIBERADMIN_VERSION = '2.0.6';
const FIBERADMIN_DEV_MODE = false;
const FIBERADMIN_FILENAME = __FILE__;
define("FIBERADMIN_DIR", plugin_dir_path(__FILE__));
Expand Down
29 changes: 0 additions & 29 deletions includes/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public function __construct(){
// SVG metadata
add_filter('wp_get_attachment_metadata', array($this, 'fiad_svg_attachment_metadata'), 10, 2);
add_filter('wp_generate_attachment_metadata', array($this, 'fiad_svg_attachment_metadata'), 10, 2);
// Fix the output of images using wp_get_attachment_image
add_filter('wp_get_attachment_image_attributes', array($this, 'fiad_svg_image_attributes'), 10, 3);
}
}

Expand Down Expand Up @@ -141,33 +139,6 @@ public function fiad_svg_attachment_metadata($data, $id){
return $data;
}

public function fiad_svg_image_attributes($attr, $attachment, $size){

// If we're not getting a WP_Post object, bail early.
// @see https://wordpress.org/support/topic/notice-trying-to-get-property-id/
if(!$attachment instanceof WP_Post){
return $attr;
}

$mime = get_post_mime_type($attachment->ID);
if('image/svg+xml' === $mime){
$default_height = 100;
$default_width = 100;

$dimensions = $this->fiad_get_svg_dimensions(get_attached_file($attachment->ID));

if($dimensions){
$default_height = $dimensions['height'];
$default_width = $dimensions['width'];
}

$attr['height'] = ceil($default_height);
$attr['width'] = ceil($default_width);
}

return $attr;
}

protected function fiad_get_svg_dimensions($svg){
$svg = @simplexml_load_file($svg);
$width = 0;
Expand Down
8 changes: 4 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: white label, admin tool, duplicate post, content protection
Requires at least: 4.7
Tested up to: 5.9.3
Requires PHP: 7.0
Stable tag: 2.0.5
Stable tag: 2.0.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -46,7 +46,7 @@ At the first time using this setting, Fiber Admin will ask you to save it to cre

== Changelog ==

= 2.0.5 =
*Release Date - 27 April 2022*
= 2.0.6 =
*Release Date - 13 May 2022*

* Fixed: Fix conflicts with SVG Support plugin.
* Fixed: Fix duplicate width height attribute for SVG images.

0 comments on commit 6339bcf

Please sign in to comment.