dotCMS / dotCMS/core

Page API: Inconsistent contentlets image field values

Open
#31,478 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type : Defect
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:

Image

As a side note, I am working on a headless implementation and using @dotcms/client along with UVE.

Cheers!

Steps to Reproduce
  1. Create a content type with an image field
  2. Create a second content type with an image field
  3. On the first content type, create a relaitionship to the second content type
  4. Create a contentlet of the first content type with an image
  5. Relate a new contentlet of the second content type (also containing an image), and relate it to the first content type
  6. Place the contentlet on a page
  7. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.