I was getting the following error on pages with inline images inserted usning insert module:

Warning: getimagesize(/sites/default/files/styles/medium/public/images/inline/page/image-1.jpg) [function.getimagesize]: failed to open stream: No such file or directory in _caption_filter_get_width() (line 103 of .../sites/all/modules/contrib/caption_filter/caption_filter.module).

Adding the following check for array_key_exists prevented the error from appearing.

  if (!empty($src_result) && array_key_exists('1', $src_result)) {
    list($width) = getimagesize($src_result[1]);
   }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jenlampton’s picture

patchy patchy.

lpelty’s picture

Thanks for the patch but I'm getting a file not found page. Can you reupload?

Thanks.

jenlampton’s picture

Hm. silly d.o! trying again.

jenlampton’s picture

Looks like that didn't solve the issue on sites where I'm using relative paths. The problem here is that caption_filter assumes we'll be providing a fully qualified URL to the image in the src tag, and when you check the use-local-paths checkbox on the insert module (which everyone should do) caption_filter module is unable to correctly locate the file from the relative path.

Here's a more comprehensive patch that checks if the image src is local or remote and acts accordingly.

jenlampton’s picture

Status: Active » Needs review
FileSize
1.4 KB

Looks like that last patch added an extra } for some reason. Trying again.

wwalc’s picture

Not sure if it makes sense to make the patch co complex. I'd go with something like:

if (!empty($src_result) && file_exists($src_result[1])) {
  list($width) = @getimagesize($src_result[1]);
}
jenlampton’s picture

I don't think that solves the local vs remote problem, as noted above. Does it?

wwalc’s picture

@jenlampton - True, I was simply using URLs to images located on an external server and wanted to get rid of the error somehow. I missed the point that your patch tries to handle absolute URLs (starting with http://) that point to local files, so it looks like a more comprehensive approach. I did not test it though.

siefca’s picture

arh1’s picture

In quick testing, #5 above works for me. Thanks, @jenlampton

kmonty’s picture

Status: Needs review » Fixed

Thanks for the patch! Confirmed this was the source of the issue. Tweaked the patch a little bit + committed.

http://drupalcode.org/project/caption_filter.git/commitdiff/aadce429b8a9...

Status: Fixed » Closed (fixed)

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

druplr’s picture

Status: Closed (fixed) » Needs review
FileSize
977 bytes
632 bytes

Thanks for the patch. I downloaded 7.x-1.x-dev (2013-Apr-10), which fixed the issue for some of my files, but I still had problem with files having space in the filename, which encodes to %20. To avoide this issue, used rawurldecode() function. Please see the attached patches.

kmonty’s picture

Status: Needs review » Closed (fixed)

Please open new tickets for new issues. Thanks!

kmonty’s picture

Issue summary: View changes

remove weirdness

aitala’s picture

Patch #5 did not work for me in all cases. Am still seeing the error for anonymous users

Warning: getimagesize(sites/default/files/styles/medium/public/img_6622.jpg?itok=Y2JO0smR): failed to open stream: No such file or directory in _caption_filter_get_width() (line 121 of .../sites/all/modules/contrib/caption_filter/caption_filter.module).

Eric

tchopshop’s picture

Having this issue still after patching both on local and live sites. These errors are really out of control.

Update: the errors were still happening after the patch because another module was hanging cron. But fixed now.

Jason2014’s picture

Issue summary: View changes

Warning: getimagesize(/home/admin/web/xxxxx.com/public_html/sites/default/files/logo.png): failed to open stream: No such file or directory in _caption_filter_get_width() (line 148 of /home/admin/web/xxxxx.com/public_html/sites/all/modules/caption_filter/caption_filter.module).

http://picpaste.com/pics/weird-Jdzfi5oP.1394646711.png

Images are not staying in the frame. Sometimes though go out side and sometimes they are too small. The above is the error I get. Im using the Dev Version.

7.x-1.x-dev zip (20.44 KB) 2014-Mar-04

[EDIT]
Patch 5 does indeed work for me. I was patching the wrong file. Using the original and not the dev worked!

thomas1977’s picture

Any plans to release a new (dev) version with the #5 included (for all us non-patchers...). Thanks.

krisahil’s picture

Re-factored the patch (I know it's already applied to 7.x-1.x branch) to account for missing local and remote images. It should apply cleanly to 7.x-1.2 release.

deanflory’s picture

Patch #19 fails against 7.x-1.x (I know you said it was already applied, but not with your fixes right?):

patch < caption_filter-refactor_image_url_discovery-1402056-19.patch
patching file caption_filter.module
Hunk #1 FAILED at 91.
1 out of 1 hunk FAILED -- saving rejects to file caption_filter.module.rej

Any chance of getting the patch rerolled against 7.x-1.x -dev or is it necessary?

kmonty’s picture

Status: Closed (fixed) » Needs review

Reopening since people are still having this issue.

Possibly related: #2059165: Trouble Getting Width of the Image

aitala’s picture

Any idea if this issue is affecting the 1.3 version?

Eric

wylbur’s picture

Status: Needs review » Needs work

We're using Panopoly and still seeing these errors on our site currently with the 1.3 module version.

Warning: getimagesize(): php_network_getaddresses: getaddrinfo failed: Name or service not known in _caption_filter_get_width() (line 151 of /public_html/profiles/panopoly/modules/contrib/caption_filter/caption_filter.module).

We're using PHP 7.2

I'll try to roll a patch and test on the latest DEV.

wylbur’s picture

Assigned: Unassigned » wylbur