Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This error can creep in:
Notice: Undefined variable: width in _caption_filter_get_width() (line 130 of /usr/local/var/www/commons/profiles/commons/modules/contrib/caption_filter/caption_filter.module).
The trouble here is that _caption_filter_get_width() is called in ways that sometimes it can't figure out the width. This leads to a wierd (100% width caption) even if the image is much smaller.
Comments
Comment #1
inversed CreditAttribution: inversed commentedWhile I don't see the error message, the end result for me is that inline styles for the div.caption-inner is being set to width:NANpx.
<div class="caption-inner" style="width: NaNpx;">
This is happening when I apply a caption to an an external image.
Comment #2
hawkeye.twolfIs this related to: #1402056: Warning getimagesize failed to open stream: No such file or directory in _caption_filter_get_width?
Comment #3
ergophobe CreditAttribution: ergophobe commentedThere are actually a few issues along these lines that I've seen using Caption Filter with Panopoly. For the time being I'm patching this on the Panopoly end, but some of this could be done more efficiently here.
One of the related issues to this one is that if the caption is really long, it will make the box wider instead of forcing the box to resize to the image size. I am currently handling this with Javascript grabbing naturalWidth.
All the gory details are here:
#2287805: Caption filter does not work with Quarter Size image format - or with floated captions.
I was planning to open an issue in the Caption Filter queue related to this, but perhaps this issue will serve that purpose.
Comment #4
kmontyHas anyone patched this? @ergophobe how is this being fixed on Panopoly? I see the js fix on #2287805: Caption filter does not work with Quarter Size image format - or with floated captions.. Definitely open to porting this to Caption Filter....
Comment #5
ergophobe CreditAttribution: ergophobe commentedWow, this is gone from the memory banks. I've been off Drupal projects almost since that post, so I really can't help much here.