Hello folks,
Some Context:
I have a custom pugin to analyze the content that in turn helps our editors to show useful insights of about the content.
I am also using a modular block for Image to select images for which the alt
attribute is configured in the media section.
Problem:
I am using the getFieldValue
method from the SDK which returns the object correctly for me. But the object contains only the uploadId
. I would also need the alt
and the url
of the uploaded image., which apparently seems to be null
.
PFA the screenshot:
Is there a way where I can get these values?
1 Like
hello! Iβm sorry but field plugins cannot reach that information. Images in media area can have alt
/ title
, yes, but when you use an image in a single asset field, for example, that image can have a custom alt
/ title
that overrides the one defined in media area.
Thatβs why you get null
values when using getFieldValue
. It means the user did not override the default alt
/ title
values defined in media area. When you fetch data via our graphql endpoint, then, we manage this for you, showing the default values, if no overridden value exists.
In your case, I think you should get the uploadId
and then make an API request to this endpoint: https://www.datocms.com/docs/content-management-api/resources/upload/self
You will be able to fetch the default alt
/ title
valures for every locale and also the url.
1 Like