# Get assets "description"-value on images

**URL:** <https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254>\
**Category:** Support\
**Created:** [March 8, 2020, 3:58pm UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254 "2020-03-08T15:58:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohagihu](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/rohagihu/32/696_2.png) [@rohagihu](https://discourse.getcockpit.com/u/rohagihu)\
**Post date:** [March 8, 2020, 3:58pm UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/1 "2020-03-08T15:58:53Z")

</div>

Hi,

is there a way to get the value of the assets field “description” (when editing asset) in the response data? If I set a collection fields type to “asset” I get this property. If I set a fields type to “gallery” or “image” I only get the “meta” - values “title” and “asset”(id). I guess I could do new request for all those asset-ids but I am looking for a cleaner solution.

Thank you

---

<div class="post-metadata">

**Author:** ![Mr\_JimWest](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/mr_jimwest/32/891_2.png) [@Mr\_JimWest](https://discourse.getcockpit.com/u/Mr_JimWest)\
**Post date:** [August 22, 2021, 9:41pm UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/2 "2021-08-22T21:41:49Z")

</div>

@rohagihu, did you ever figure this out? I’ve got the same question. 🤔

---

<div class="post-metadata">

**Author:** ![rohagihu](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/rohagihu/32/696_2.png) [@rohagihu](https://discourse.getcockpit.com/u/rohagihu)\
**Post date:** [August 23, 2021, 8:10am UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/3 "2021-08-23T08:10:55Z")

</div>

@Mr_JimWest unfortunately not. I’ve used field type “set” as workaround for composing image+text.

---

<div class="post-metadata">

**Author:** ![abernh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/abernh/32/859_2.png) [@abernh](https://discourse.getcockpit.com/u/abernh)\
**Post date:** [August 23, 2021, 2:51pm UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/4 "2021-08-23T14:51:57Z")

</div>

I assume you are referring to the empty `description` key in the assets data object when you retrieve an entry which has a “linked” asset.

The problem seems to be the way assets are linked/stored with a collection entry.

Once you select an asset its data object is not simply linked but stored with the collection entry.

Once you edit the linked asset (and therefore change its data object), those changes are not copied over to the collection entry.

You have to go “asset \> replace \> select-once-more-the-same-asset \> save” and only then the updated description is suddenly showing when querying the entry.

Not sure how this feature/bug is to be treated. But these are the technicalities around this problem.

A “fix” would be

1. on updating an asset to update all entries that “somehow” have the respective asset linked to them  
- or -
2. to repopulate asset fields on “retrieve” with the latest info from the assets collection (instead of relying on a possibly outdated “local copy” of the assets data object).

(2) could be implemented by yourself in a “GET” rule script. As a local fix for your collections asset fields.

---

<div class="post-metadata">

**Author:** ![Mr\_JimWest](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/mr_jimwest/32/891_2.png) [@Mr\_JimWest](https://discourse.getcockpit.com/u/Mr_JimWest)\
**Post date:** [August 29, 2021, 3:13am UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/5 "2021-08-29T03:13:59Z")

</div>

@rohagihu, thanks for the reply.

@abernh, the issue is not that we are getting bad/outdated data, it’s that the collection’s JSON does not output the ‘description’ for ‘image’ field types in the first place. As soon as we change the image field to an ‘asset’ field type, it works as expected.

Is it possible to change what does and does not show in the JSON?

---

<div class="post-metadata">

**Author:** ![Mr\_JimWest](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/mr_jimwest/32/891_2.png) [@Mr\_JimWest](https://discourse.getcockpit.com/u/Mr_JimWest)\
**Post date:** [August 29, 2021, 7:35pm UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/6 "2021-08-29T19:35:34Z")

</div>

@abernh, as you mentioned…now that I take a look at at the asset field type; sure enough, it’s not updating the content either. And as you suggested, selecting “Replace”, and selecting the same file again does the trick. Thanks for the insight. 👍

---

<div class="post-metadata">

**Author:** ![abernh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/abernh/32/859_2.png) [@abernh](https://discourse.getcockpit.com/u/abernh)\
**Post date:** [August 30, 2021, 7:35am UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/7 "2021-08-30T07:35:40Z")

</div>

> [@Mr\_JimWest](#):
>
> it’s that the collection’s JSON does not output the ‘description’ for ‘image’ field types in the first place.

I made some tests with an `image` field and I don’t see any issues. All the meta information that I add is correctly saved and also returned by the API.

These are my image field params:

```auto
{
  "meta": {
    "title": {
      "type": "text",
      "label": "Title"
    },
    "description": {
      "type": "text",
      "label": "Description"
    }
  }
}

```

and this is what the API returns

```auto
   {
      "_id": "6123b44c6138326b83000331",
      ...
      "image1": {
        "path": "Sometestimage.png",
        "meta": {
          "title": "meta title",
          "description": "meta description"
        }
      }
    },

```

---

<div class="post-metadata">

**Author:** ![Mr\_JimWest](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/mr_jimwest/32/891_2.png) [@Mr\_JimWest](https://discourse.getcockpit.com/u/Mr_JimWest)\
**Post date:** [August 31, 2021, 12:35am UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/8 "2021-08-31T00:35:53Z")

</div>

This **does** appear to work; but it does not _connect_ the metadata already on the image itself.

If I upload an image to a folder in the assets ‘library’, add a title and description, and add that image to the image field-type on three different collection entries, the previously added title and description does not get passed through to the entry or the JSON; and with your method, would have to be added three times; one to each page. Changing the “image” field type to “asset” solves this; the default metadata shows up in the JSON as expected.

My current projects is going to be dealing with lots of photography. I initially thought making a collection of just the photos; and the needed metadata, would work, but then I realized that their is no way to really preview the photos in the collection. Clicking each little photo icon, or having an extremely detailed title/description does not sound fun. But, if the metadata that’s pulled through isn’t updated when the asset’s metadata is updated, I may need to go this route…I suppose I could just use that image ID and do a separate request for each image. 😆

I appreciate your guidance @abernh

---

<div class="post-metadata">

**Author:** ![abernh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/abernh/32/859_2.png) [@abernh](https://discourse.getcockpit.com/u/abernh)\
**Post date:** [August 31, 2021, 8:36pm UTC](https://discourse.getcockpit.com/t/get-assets-description-value-on-images/1254/9 "2021-08-31T20:36:23Z")

</div>

> [@Mr\_JimWest](#):
>
> the previously added title and description does not get passed through to the entry or the JSON

The described functionality for the `image` type sounds to me that it works as expected.  
If you save an asset only as an `image`, then this is a single instance of this asset and the added information about title, details etc are only meta information related to each specific `image` instance.

> [@Mr\_JimWest](#):
>
> My current projects is going to be dealing with lots of photography. I initially thought making a collection of just the photos; … then I realized that their is no way to really preview the photos in the collection.

Yes, this would have been my next thought as well and the resulting bad UX is an unexpected downside to it.  
To fix that shortcoming you would have to extend the form view.

But those are then your 2 options

- going for your “custom asset collection” and fixing the bad UX
- or using the original `asset` field type and fixing the sync

I’d say the latter might be less work (“data-transforming” seems easier than UI adjusting).
