Page API: Inconsistent contentlets image field values
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Parent Issue
No response
Problem Statement
I wasn't sure of the best way to report this, it comes down to two problems regarding contentlet data for image fields in the Page API and Content API (search).
- Contentlets placed on page, the values for image fields is just the identifier of the File Asset.
- Related contentlets image field values, the child contentlet(s) value for image fields is an object representation of the File Asset, including metadata, and other fields that might exist for the File Asset.
On the frontend, this creates a problem. When dealing with image fields, you're stuck with handling image fields in two different ways. If the contentlet is a child contentlet, you must treat the image as a File Asset object, which is actually ideal, you have everything you need. On the other hand, page contentlets don't have this information, so if you needed said data, you would need to make a separate call to get it. If a page has dozens of images, this is burdensome.
If for example, if image alt/title is stored in the File Asset, you're forced to make a separate request to the Content API to get the remaining data you need. More common use cases might be needing the image MIME type, EXIF data, image dimensions, etc.
Ideally, we would want these to be consistent. More ideally, include the image object for the Page API contentlets, as well as the Content API.
Here is a screenshot from an example Page API response illustrating the differences:
As a side note, I am working on a headless implementation and using @dotcms/client along with UVE.
Cheers!
Steps to Reproduce
- Create a content type with an image field
- Create a second content type with an image field
- On the first content type, create a relaitionship to the second content type
- Create a contentlet of the first content type with an image
- Relate a new contentlet of the second content type (also containing an image), and relate it to the first content type
- Place the contentlet on a page
- Use the Page API to see the JSON data of the page
Acceptance Criteria
Best outcome (might have breaking changes)
Both the page's contentlets' and related contentlets' image fields have the full File Asset data for image field values in Page/Content API JSON.
dotCMS Version
All versions, agile and LTS
Proposed Objective
Technical User Experience
Proposed Priority
Priority 3 - Average
External Links... Slack Conversations, Support Tickets, Figma Designs, etc.
No response
Assumptions & Initiation Needs
No response
Quality Assurance Notes & Workarounds
No response
Sub-Tasks & Estimates
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the difference between Page API contentlets and related Content API contentlets using the listed image-field steps, then trace how both responses represent File Assets. Done means image fields consistently expose the full File Asset data in both Page and Content API JSON, with the breaking-change implications considered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100