Skip to content

Bug Report: WordPress Plugin ignores “Enable SVG support” for down-synced Cloudinary assets (imports PNG) #1087

@TheRealFreelancer

Description

@TheRealFreelancer

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

  1. Upload an SVG file directly into Cloudinary (not via WordPress).
    • Asset is stored as SVG in Cloudinary, no transforms/presets applied.
  2. In WordPress, go to Cloudinary → Add from Cloudinary and import that SVG asset.
  3. The imported attachment in WordPress Media Library is registered as PNG (.png URL, MIME image/png).
  4. If you upload the same SVG via WordPress, the plugin correctly stores it in Cloudinary and registers it as SVG (.svg URL, MIME image/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 method get_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' from get_convertible_extensions().
  • Ensure down-sync/import logic respects SVG support and sets resource_type = raw for 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions