Problem/Motivation

This comes from #1967656-8: Add views support. Today we override the default image formatter to add the caption, so there is no way to show the image with no caption, or the caption alone without the image.

Proposed resolution

Remove our hook_theme_registry_alter and define two new formatters (one that replicates the current functionality showing the image and the caption and another to show the caption only), leaving the default image formatter alone. This way the site builder can choose between displaying the image, the caption or both.

Remaining tasks

In #1967656-9: Add views support @hanoii suggested we also provide an update_hook:

(...) there should be an upgrade code that will change the formatters of the current image field with caption so that the people updating the module (eventually) should still see the same behavior as they had when the installed the module.

I'm not sure what to to do about this, since other modules (views or panels for example) can also have image fields using the default formatter. Should we attempt to upgrade only content type display settings and add a note about manually changing the others?

User interface changes

The site builder should now explicitly select the Image with caption formatter in order to have today's default behaviour.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpv created an issue. See original summary.

mpv’s picture

Here's a patch with the proposed resolution. There is no hook_update yet.

mpv’s picture

Status: Active » Needs review
iStryker’s picture

I pretty sure this is what I did in https://www.drupal.org/node/2345635#comment-9706103. Your code might be cleaner. I have not had the time to look into this issue for awhile.

iStryker’s picture

About the update hook:

Take the example of you having a website that is currently using captions everywhere (as that is the only option with this module enabled). When you patch something, you want to update the database to keep the current state.....not break something....not force the user to manually change the value, etc.

mpv’s picture

Oh! I've missed your issue. Yes, this is the same only with an extra formatter for the caption alone.

Regarding the update hook, I agree. I was just pointing out that we might not know all the tables where modules could be storing that information. I can think about views and panels, but there might be some other more obscure module we don't know about that we don't update. So perhaps we should update views and panels and the core field tables (anything else?), and add a message regarding any other module that may be using the formatter stored in a custom table?

Anyway, here's a new patch with an update hook that upgrades the display settings for all the fields currently using the image formatter. Still missing views and panels, will try to do that this week but I can't promise I will have the time.

iStryker’s picture

Update hook should probably inclue views and panels. I would not worry about the obscure modules. If people have problems, then they'll create an issue and we will all try to help them. Better to aim for the 80% than 100%

vistree’s picture

Didn't test the update prozess - but the caption works fine in views. The only question: alt and title attributes are avaible by rewriting the image-field in views. Wouldn't it be consequent to do the same with the caption?

bc’s picture

Looks like this is in 2.x-dev via commit 164c5cbd49706e9e6ddee614c8bb8f2d2e420feb.

nubeli’s picture

I've rerolled the patch. I don't think there should be an update hook to update all the formatters since it should be up to the site admin to choose which formatter to use.

@vistree I suggest a new issue for making caption available for rewriting the image field in Views, it's unrelated to this issue.

I'm guessing by the age of this issue that it'll probably not get merged and we'll need to keep maintaining the patches.

tyler.frankenstein’s picture

If this issue can get to a confident RTBC, then I don't have an issue committing it. I personally don't use this module anymore, so I am relying on the community to assure it's quality.

iStryker’s picture

Status: Needs review » Closed (outdated)

Closing all 7.x issues.