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') {
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | less-strict-caption-flag-comparison-operator-2837386-9.patch | 977 bytes | foxtrotcharlie |
| #2 | fix_field_title_captions-2837386-2.patch | 614 bytes | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedBWPanda created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedComment #4
amaria commentedNice catch! Committed.
Comment #5
jastraat commentedThis 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.
Comment #6
jastraat commentedIf 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
Comment #7
brauny commentedThis "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!
Comment #9
foxtrotcharlie commentedYeah, 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 :-)
Comment #10
berenddeboer commentedfoxtrotcharlie's patch is better, can we please use that? I can't reopen this, but I suggest we take his patch.