Missing file entity filesize property

Created on 17 June 2024, 12 days ago

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.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium klaasvw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @klaasvw
  • πŸ‡§πŸ‡ͺBelgium klaasvw

    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.

  • Status changed to Needs review 12 days ago
  • πŸ‡§πŸ‡ͺBelgium klaasvw
Production build 0.69.0 2024