Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions php/class-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,22 @@ public function is_active() {
return 'on' === $this->config[ $this->enable_slug ];
}

/**
* Disable SVG conversion.
* If SVG support is active, we don't want to convert SVGs to other formats.
*
* @param array $base_types The base types for conversion.
*
* @return array
*/
public function disable_svg_conversion( $base_types ) {
if ( $this->is_active() && ! empty( $base_types['svg'] ) ) {
unset( $base_types['svg'] );
}

return $base_types;
}

/**
* Setup the component
*/
Expand All @@ -233,6 +249,7 @@ public function setup_hooks() {
add_filter( 'cloudinary_allowed_extensions', array( $this, 'allow_svg_for_cloudinary' ) );
add_filter( 'cloudinary_upload_options', array( $this, 'remove_svg_eagers' ), 10, 2 );
add_filter( 'cloudinary_upload_args', array( $this, 'upload_args' ), 10, 2 );
add_filter( 'cloudinary_convert_media_types', array( $this, 'disable_svg_conversion' ) );

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