elegantthemes / Divi-Beta

8 stars 0 forks source link

UploadContainer And Image Metadata #37

Open dtcblyth opened 10 months ago

dtcblyth commented 10 months ago

Related thread: https://discord.com/channels/1041765492907589683/1157236208762638379

Problem:

When using the <UploadContainer /> component for images, there doesn’t appear to any built-in helper functions for getting the image’s metadata, such as: titleText, altText, caption, description, etc.

Currently we can only get these values using the RestAPI, but this requires an additional call to the server. Furthermore, because the resolved value for the <UploadContainer /> is the image url, we are forced to use the attachment_url_to_postid() function to get the image post id.

Solution:

Considering the Visual Builder is fetching the image anyway, would it not be possible to also get the images metadata at the same time? Instead of returning only the image URL, perhaps the <UploadContainer /> could return an object which includes, the image url, id, and other metadata.