When I enable captions to be the 'title' field in my field formatter settings, captions don't display. I worked out that this is because in the following code it's checking if the caption setting is an integer, whereas it's stored as a string.

if ($display['settings']['caption'] === 1) {

Changing it as follows makes captions work properly:

if ($display['settings']['caption'] === '1') {

Comments

Anonymous’s picture

BWPanda created an issue. See original summary.

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new614 bytes

  • amaria committed 0faeac7 on 7.x-2.x authored by BWPanda
    Issue #2837386 by BWPanda: Field 'title' captions don't work
    
amaria’s picture

Status: Needs review » Fixed

Nice catch! Committed.

jastraat’s picture

This change broke all flexslider featurized caption settings because the setting was being stored as an integer in features. But now the comparison no longer works. Unfortunately features doesn't see a difference between '1' and 1 when doing checks for overridden features, so even updating the feature to use strings and then feature reverting does not fix the issue.

jastraat’s picture

If someone else runs into this, you can manually recreate all your features with flexslider settings to wrap the caption option in single quotes and then force a feature revert with drush fr [your feature name] --force -y

brauny’s picture

This "broke" non-featurized captions too. I had set my "title" field to be the image caption in the display settings for multiple fields. The solution was to simply "re-save" the display settings for all of the affected fields. Hopefully this helps someone!

Status: Fixed » Closed (fixed)

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

foxtrotcharlie’s picture

Yeah, also an issue with one of my features. I had to manually add the quotes around the 1 in the feature.

Why do we need such a strict comparison? How about using '== 1' instead to cater for both cases?

Attached patch should work for both if you'd like to use it :-)

berenddeboer’s picture

foxtrotcharlie's patch is better, can we please use that? I can't reopen this, but I suggest we take his patch.