-
Couldn't load subscription status.
- Fork 31
Closed
Description
Bug Report: WordPress Plugin ignores “Enable SVG support” for down-synced Cloudinary assets (imports PNG)
Environment
- Cloudinary WordPress Plugin: 3.2.12
- WordPress: latest
- SVG support toggle in plugin settings: enabled
Steps to Reproduce
- Upload an SVG file directly into Cloudinary (not via WordPress).
- Asset is stored as SVG in Cloudinary, no transforms/presets applied.
- In WordPress, go to Cloudinary → Add from Cloudinary and import that SVG asset.
- The imported attachment in WordPress Media Library is registered as PNG (
.pngURL, MIMEimage/png). - If you upload the same SVG via WordPress, the plugin correctly stores it in Cloudinary and registers it as SVG (
.svgURL, MIMEimage/svg+xml).
Expected Behavior
With Enable SVG Support active, importing an existing Cloudinary SVG into WordPress should preserve it as SVG (URL ending .svg, MIME image/svg+xml).
Actual Behavior
For down-synced/imported assets, the plugin treats SVG as “convertible” and replaces it with a PNG variant.
Technical Notes
- In
php/class-media.php, the methodget_convertible_extensions()includes:'svg' => 'png',
- This conversion logic runs during import/sync and overrides the SVG support logic in
php/class-svg.php. - As a result, “Enable SVG support” is ignored for the down-sync/import path.
Workaround
Adding these filters in a MU-plugin fixes the behavior:
// Prevent SVG → PNG conversion
add_filter('cloudinary_convert_media_types', function ($types) {
unset($types['svg']);
return $types;
});
// Force resource_type raw for SVG
add_filter('cloudinary_resource_type', function ($type, $id) {
if (get_post_mime_type($id) === 'image/svg+xml') return 'raw';
return $type;
}, 10, 2);
// Disable eager formats for SVG
add_filter('cloudinary_upload_eager_formats', function ($formats, $id) {
if (get_post_mime_type($id) === 'image/svg+xml') return [];
return $formats;
}, 10, 2);Suggested Fix
- If SVG support is enabled, remove
'svg' => 'png'fromget_convertible_extensions(). - Ensure down-sync/import logic respects SVG support and sets
resource_type = rawfor SVG assets. - Automatically disable eager transformations for SVG.
Impact: Without this fix, SVG support only works for assets uploaded via WordPress, not for assets that already exist in Cloudinary.
Metadata
Metadata
Assignees
Labels
No labels