Problem/Motivation

The filter module from core provides a filter to display image captions and align images: FilterCaption. This filter in itself does not requires the DOM element to be an <img> tag, but in tips, description, comments etc. it mentions the term image. Although, in short description it mentions that it can be used elements other than image:

return $this->t('You can caption (data-caption="Text") and align images (data-align="center"), but also video, blockquotes, and so on.');

But when this is used by the CKEditor module in 'drupalimagecaption' plugin (DrupalImageCaption and ckeditor/js/plugins/drupalimagecaption/plugin.js), it restricts its usage to just images. Although with few changes, this plugin can be generalized to all elements. By doing this, we are saving a lot of code from being replicated by modules which want to provide a similar caption/align features (for instance entity_embed, and maybe video also).

Proposed resolution

First task is to generalize the FilterCaption documentation so that it uses the term 'entity' instead of 'image' and modify/add examples to explain that div will work for elements other than image.

Next task will be to generalize the CKEditor plugin to remove its dependency on img element. Also, in case we do this, we'll want to rename 'drupalimagecaption' to 'drupalentitycaption' or something similar.

Since this filter is used in a couple of tests also, they will also need to be changed, but that should be as simple as changing the name of the class.

Remaining tasks

Write a patch.
Test it.

User interface changes

None.

API changes

None.

Comments

cs_shadow’s picture

Issue summary: View changes
Dave Reid’s picture

Wim Leers’s picture

Status: Active » Postponed
Issue tags: +CKEditor in core

Let me start by saying that I'd love to have this also.

But — sadly — AFAIK this can't be done. Please see #2284689-6: How can other modules that add WYSIWYG content reuse the data-caption and data-align attributes? and #2284689-9: How can other modules that add WYSIWYG content reuse the data-caption and data-align attributes? for my explanation, plus the upcoming explanation from a CKEditor developer.

Marking as postponed for now, until we get the definite confirmation from a CKEditor developer that this is impossible. If it turns out to be possible after all, we can reopen this. If it's confirmed to be impossible, we can close this.

Wim Leers’s picture

Version: 8.0.x-dev » 8.1.x-dev
Category: Task » Feature request

Tempted to close this per #2284689-10: How can other modules that add WYSIWYG content reuse the data-caption and data-align attributes?, but keeping as a feature request to be considered for a future version for now.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

Status: Postponed » Closed (outdated)

I was tempted to close this in #4, >2 years ago. Now actually closing.