Problem/Motivation

When saving a new Cloudinary media entity using the provided media source in the cloudinary_media_library_widget module, the filesize attribute is not populated. This is especially a problem when using the CloudinaryRaw field type for using files and documents stored in Cloudinary.

Steps to reproduce

* Enable the cloudinary_media_library_widget module
* Create a new media type using Cloudinary as source and CloudinaryRaw / document as source type
* Create a media entity of this type
* Result: the filesize is not displayed when the media entity is rendered

Proposed resolution

When generating a file entity set the filesize property as was done in the past with the cloudinary media type plugins.

Issue fork cloudinary-3455065

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

klaasvw created an issue. See original summary.

klaasvw’s picture

StatusFileSize
new1.47 KB

The following change will fetch the asset meta data and use the bytes property from cloudinary as the filesize property.

There's also an opportunity to reduce API hits and improve performance by caching the various CloudinaryAssetHelper calls. For example, when calling CloudinaryAssetHelper::loadAssetByPublicId multiple times Drupal is hitting the Cloudinary admin API more than is needed. Could be optimized by storing the assets in memory using a map in the CloudinaryAssetHelper service instance. I didn't implement this for now because it's not required for this change, but might be worth creating a new issue for this.

klaasvw’s picture

Status: Active » Needs review
klaasvw’s picture

StatusFileSize
new1.29 KB

Updated patch that checks if the assets exists (see #3479575: Handle deleted assets)