Skip to content

Commit 75a6e0a

Browse files
Do not convert SVGs pulled from Cloudinary
1 parent 05e87d4 commit 75a6e0a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

php/class-svg.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ public function is_active() {
217217
return 'on' === $this->config[ $this->enable_slug ];
218218
}
219219

220+
/**
221+
* Disable SVG conversion.
222+
*
223+
* @param array $base_types The base types for conversion.
224+
*
225+
* @return array
226+
*/
227+
public function disable_svg_conversion( $base_types ) {
228+
if ( $this->is_active() && ! empty( $base_types['svg'] ) ) {
229+
unset( $base_types['svg'] );
230+
}
231+
232+
return $base_types;
233+
}
234+
220235
/**
221236
* Setup the component
222237
*/
@@ -233,6 +248,7 @@ public function setup_hooks() {
233248
add_filter( 'cloudinary_allowed_extensions', array( $this, 'allow_svg_for_cloudinary' ) );
234249
add_filter( 'cloudinary_upload_options', array( $this, 'remove_svg_eagers' ), 10, 2 );
235250
add_filter( 'cloudinary_upload_args', array( $this, 'upload_args' ), 10, 2 );
251+
add_filter( 'cloudinary_convert_media_types', array( $this, 'disable_svg_conversion' ) );
236252

237253
// Add actions.
238254
add_action( 'cloudinary_uploaded_asset', array( $this, 'maybe_setup_metadata' ), 10, 2 );

0 commit comments

Comments
 (0)