Skip to content

Commit

Permalink
added safe_svg_pre_dimensions filter in the svg_dimensions function
Browse files Browse the repository at this point in the history
  • Loading branch information
sksaju committed Nov 27, 2023
1 parent ebc0531 commit daadc14
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,23 @@ public function metadata_error_fix( $data, $post_id ) {
* @return array|bool
*/
protected function svg_dimensions( $attachment_id ) {
/**
* Calculate SVG dimensions and orientation.
*
* This filter allows you to implement your own sizing. By returning a non-false
* value, it will short-circuit this function and return your set value.
*
* @param boolean Default value of the filter.
* @param integer $attachment_id The attachment ID of the SVG being processed.
*
* @return array|false An array of SVG dimensions and orientation or false.
*/
$short_circuit = apply_filters( 'safe_svg_pre_dimensions', false, $attachment_id );

if ( false !== $short_circuit ) {
return $short_circuit;
}

if ( ! function_exists( 'simplexml_load_file' ) ) {
return false;
}
Expand Down

0 comments on commit daadc14

Please sign in to comment.