Skip to content

Commit

Permalink
deactivate svg_dimensions call for sponsor SVG output (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyabraham committed Aug 6, 2020
1 parent fca2b23 commit b318356
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions web/wp-content/plugins/safe-svg/safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ protected function svg_dimensions( $svg ) {
* (in that order). Default 'thumbnail'.
*/
public function fix_direct_image_output( $attr, $attachment, $size = 'thumbnail' ) {
if ( ! apply_filters( 'safesvg_try_calculate_image_sizes', '__return_true' ) ) {
return $attr;
}

// If we're not getting a WP_Post object, bail early.
// @see https://wordpress.org/support/topic/notice-trying-to-get-property-id/
Expand Down
7 changes: 6 additions & 1 deletion web/wp-content/plugins/sponsors-dynamic-block/src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ function( $sponsor ) {
$out .= '<h3 class="sponsors-logos--header">' . $tier_name . '</h3>';
$out .= '<div class="sponsors-logos ' . $tier_size . ' ' . get_sponsor_logos_class( $query->found_posts ) . '">';

// temporarily deactivate the size calculation for SVGs.
add_filter( 'safesvg_try_calculate_image_sizes', '__return_false' );

while ( $query->have_posts() ) {
$query->the_post();

Expand All @@ -137,7 +140,9 @@ function( $sponsor ) {
}
$out .= '</div>';
}

// reactivate size calculations for SVGs.
remove_all_filters( 'safesvg_try_calculate_image_sizes' );

$out .= '</div></div>';

/* Restore original Post Data */
Expand Down

0 comments on commit b318356

Please sign in to comment.