Skip to content

Commit

Permalink
PHPCS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-glo committed Jul 22, 2024
1 parent 79fb26b commit b630031
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function fix_admin_preview( $response, $attachment, $meta ) {
*/
public function one_pixel_fix( $image, $attachment_id, $size, $icon ) {
if ( get_post_mime_type( $attachment_id ) === 'image/svg+xml' ) {
$dimensions = $this->set_svg_dimensions( $size, $attachment_id );
$dimensions = $this->set_svg_dimensions( $attachment_id, $size );

if ( $dimensions && $dimensions['height'] && $dimensions['width'] ) {
$image[1] = $dimensions['width'];
Expand Down Expand Up @@ -451,7 +451,7 @@ public function load_custom_admin_style() {
public function get_image_tag_override( $html, $id, $alt, $title, $align, $size ) {
$mime = get_post_mime_type( $id );
if ( 'image/svg+xml' === $mime ) {
$dimensions = $this->set_svg_dimensions( $size, $id );
$dimensions = $this->set_svg_dimensions( $id, $size );

if ( $dimensions['height'] && $dimensions['width'] ) {
$html = str_replace( 'width="1" ', sprintf( 'width="%s" ', $dimensions['width'] ), $html );
Expand Down Expand Up @@ -720,14 +720,13 @@ protected function str_ends_with( $haystack, $needle ) {
/**
* Set custom width or height of the SVG image.
*
* @param string $dimension Dimension quality of the image. Either 'width' or 'height'.
* @param string|array $size Size of image. Image size or array of width and height values
* @param int $id Image attachment ID.
* @param string|array $size Size of image. Image size or array of width and height values
* (in that order). Default 'thumbnail'.
* @param int $id Image attachment ID.
*
* @return int|false Width or height of the SVG image, or false if not found.
*/
protected function set_svg_dimensions( $size, $id ) {
protected function set_svg_dimensions( $id, $size ) {
$dimensions = $this->svg_dimensions( $id );

if ( is_array( $size ) ) {
Expand Down

0 comments on commit b630031

Please sign in to comment.