Skip to content

Unable to access ckeditor custom fields when set on assets #355

Description

@mindshaped

Description

We've set a custom field for all assets on a craft 5 installation, which works well as long as the custom field is the native plain-text field from craft. But as soon as the custom field is set as ckeditor field, it is not accessible anymore on the frontend via twig functions. Is this out of reach for the ckeditor plugin, or should it be accessible?

In more detail, we have created a custom field with name "caption" (to be used additionally to the native alt-field). when set to plain text, outputting it works well by using {{ image.caption }} (after the needed image-query) – but as soon as the field is a ckeditor-field it's an empty output.

Steps to reproduce

  1. create new custom field for assets, as described on https://craftcms.com/docs/5.x/reference/element-types/assets.html#asset-custom-fields
  2. add contents to the custom field on an example entry with assets
  3. try to output the custom field in the frontend with twig code {{ image.caption }}
  4. other way that have been tried: {{ image.caption.getContent() }} or {{ image.getFieldLayout().getCustomFields()|map(field => field.handle == 'caption' ? field.getContent() : null)|first }} which all result in errors cause image.caption is empty for ckeditor fields.

Additional info

  • Craft version: 5.5.10
  • PHP version: 8.2.27
  • Plugins & versions: CKEditor 4.4.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions