Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tyler.frankenstein’s picture

Status: Active » Needs work

At this point I myself don't have any plans to port this to D8 until I need it. That being said, it is open source, so if you've started to make progress on it, please post any patches here, thanks.

drupalfan2’s picture

Is there any other module or other solution for Drupal 8?

tyler.frankenstein’s picture

Status: Needs work » Active
spoit’s picture

Marked #2775147: What about Drupal 8? as duplicate of this issue.

Echofive’s picture

Hello everybody,

The first version compatible for Drupal 8 is available here:
https://www.drupal.org/sandbox/spoit/2806183
http://cgit.drupalcode.org/sandbox-spoit-2806183/tree/?h=wieni-8.x-1.x

Kind regards ;)

Echofive.

millionacrenest’s picture

#5 works great, looks great. Thanks!

sachbearbeiter’s picture

Thanks a lot - i will try to use it in the next project ...

Regards
SB

Ambient.Impact’s picture

I've gotten #5 working on Drupal 8.7.3, but I had to make some changes to fix some fatal errors:

  • Quoted the storage service arguments as they contain @ which Symfony's YAML parsing chokes on.
  • Copied the contents of template_preprocess_image_formatter() into template_preprocess_image_caption_formatter() as the former is in an include that's only loaded when needed, and does not get loaded if using a different formatter (i.e. the caption formatter). It's probably against Drupal best practices to run a specific preprocess function as well, since it bypasses the theme system and doesn't allow other modules to have their say.
Ambient.Impact’s picture

An update to my previous patch with a fix for a fatal error when _image_field_caption_widget_process runs during a Views Bulk Operations view.

fredonia_webteam’s picture

Are there any updates on this port?

dercheffe’s picture

This should be shipped with core media module IMO :)
Any news about this port?

Ambient.Impact’s picture

I've been using this for a while, but the more I've thought about it, the more I think that the way forward is to add a text field on the core image media entity, since media is the way forward for Drupal core. I think that's preferable and much more flexible than what this module does, which hard codes a single caption and has to set up storage for it, etc., which you get for free when you add fields to a media entity.

awm’s picture

I created a patch file based on #5. credit goes to https://www.drupal.org/sandbox/spoit/2806183

AaronBauman’s picture

Any reason not to tag an 8.x release from the sandbox project or the github project?
https://github.com/wieni/image_field_caption

tyler.frankenstein’s picture

Would anyone like to volunteer to be the D8 maintainer? Please DM me.

I figure that the sandbox/patch can be used as the starting grounds.

UPDATE: Please welcome ironsizide and awm as new maintainers!

awm’s picture

I noticed couple of issues that I fixed in the latest patch.
1. Required is not being set when using image fields with caption in paragraphs.
2. issues with multi-values image fields, when adding additional caption field in node form, the previous ones are being overwritten with empty value or being reset.

awm’s picture

patch #17:
- cleaned up some code that does appear to be necessary
- fix issues with values disappearing in a multi-value fields
- handle required field setting in a similar fashion to how the core alt field is handled.

one issue remains is that when the format of the caption is html or full html, the required settings does not work.

Please test this as a single field, multivalue field, and a paragraph field .. would love some feedback.

awm’s picture

This still needs some work:
1.Support revisions
2. Ensure the caption field work with multivalue setting.
3. Ensure the field work on paragraphs.

Attaching a patch that fixed issues with paragraphs.

awm’s picture

Status: Active » Needs work
awm’s picture

@Ambient.Impact I agree with your comment I think I have seen some feature requests in core to add caption in addition to alt and title. In fact there are modules in some issues, (see below) , that allow the use of either "alt" or "title" as caption but non of them add a dedicated caption property to the image.
Ideally this module can be rewritten to to alter the core image and add the caption property instead of having the caption separated and handling the storage ourselves

relevant issues in core:
- https://www.drupal.org/project/drupal/issues/2305109
- https://www.drupal.org/project/drupal/issues/2768951

In any case, I created a new branch for 8.x-1.x based on the work gathered here. We need to update the project page to reflect the status of the module.
https://git.drupalcode.org/project/image_field_caption/commits/8.x-1.x

  • awm committed 5204426 on 8.x-1.x
    Issue #2413809 by awm: Port to Drupal 8: fixes issues with required...
ironsizide’s picture

Status: Needs work » Active

I must admit I''m unclear as to what I should be doing as D8 maintainer at this juncture. This still needs work and not ready for a stable release yet, correct? Should I be the one updating the project page?

Ambient.Impact’s picture

@awm Fair enough. Thanks for the links.

Hopefully the default template can also use <figure> and <figcaption> elements rather than the <blockquote> in spoit's port and generate the link with the link() Twig function so it can be altered. I have my own image-caption-formatter.html.twig that does just that

Nelo_Drup’s picture

Hello any news about this module for drupal 8, is it stable or even and is it recommended to use it?

Ambient.Impact’s picture

@Nelo_Drup Looks like a stable release was made yesterday (yay!), but it's not installable because of an incorrect dependency.

Ambient.Impact’s picture

Looks like the 1.1 release fixed my previous comment and we now have a working, stable Drupal 8/9 version. Should this issue be closed now?

Wim Leers’s picture

Ambient.Impact’s picture

#27: Awesome, thanks! I think my thoughts on the subject have gone back and forth since I posted that comment:

  • On the one hand, using text fields on the media entity can make site building a lot easier for non-developers, so the UX is better and can be more flexible.
  • On the other hand, exposing it as a field like that poses a bunch of problems:
    • What if a site builder changes the media entity image field settings so that multiple images can be uploaded to one media entity? Do we now have one caption for all those images? I think people usually expect a 1:1 relationship between an image and a caption, but I could be wrong.
    • How do we correctly structure the template to use a <figcaption></figcaption> if we potentially have multiple images as an edge case? Is it valid HTML to have a <figure></figure> with multiple images and one <figcaption></figcaption>? I'm a bit short on time, so maybe someone can check the HTML spec here.
iStryker’s picture

Status: Active » Fixed

Dont know why this ticket is still open. This was done. Drupal 8 is unsupported now and there is Drupal 10 release. Marking as fixed as this was actually done.

(FYI I have not read all the comments)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.