Since I updated to Drupal 7.20, some responsive images of my website are not visible. That is the case for the images uploaded/created after the core update. (Images not controlled by this module are fine.)

Cf. the update notes of the current core release about an important change in image generation: drupal-7.20-release-notes:

... any code which programmatically generates a link to an image derivative without using the standard image_style_url() API function will no longer work correctly if the image does not already exist in the file system ...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Olafski’s picture

Addendum: See also a similar issue (with patch) concerning the Insert module: #1923336: Insert module doesn't work with Drupal 7.20

David_Rothstein’s picture

Title: Doesn't work with drupal 7.20 » Responsive images and styles module doesn't work with Drupal 7.20

Changing the title a bit, since I'm going to link to this from the Drupal 7.20 release announcement and release notes (in the "known issues" section)...

From a quick look at the code it wasn't obvious to me where the issue was, but it certainly seems possible that something won't work here.

Richard Moger’s picture

Hi all,

I can confirm 7.20 breaks responsive images 1.3.

Issue manifests itelf as 403 access denied error for imagecache style generated via responsive images. As pointed out by Olafski if the image exists it's of course fine.

I just now got resp_img working on a vanilla site under 7.19 but the same site wasn't working before under 7.20 (I had almost given up on module). I am using aegir and migrated the site back to new build of 7.19 to test.

My bad timing that I just started with this module yesterday on a site I just updated to 7.20!

Rich

ericaordinary’s picture

Same issue after the upgrade to 7.20. It took me ages to narrow this one down to the core upgrade. I've tested fresh copies of my install profile on 7.18 (my previous platform) and 7.20 and 7.20 does indeed returns 403's for all the images.

My image styles are all living in Features, so I tried overriding and resaving one set of responsive styles, and although this created the relevant empty directories (ie sites/default/files/styles/*mystyle*/public) it still didn't save the new images to those directories or fix the 403 problem.

If you have upgraded and need a quick and dirty fix, adding $conf['image_allow_insecure_derivatives'] = TRUE; to your settings.php as per the Release Notes will work, but circumvents the security fix put in place so kinda defeats the purpose of the security update.

I'll have a dig around on this one, as it's a key feature of the project I'm working on at the moment.

Has anyone tried v2.x with Drupal 7.20 to see if it has the same problem?

David_Rothstein’s picture

Status: Active » Needs review
FileSize
1.6 KB

The attached patch fixes the problem for me for the basic use case of this module (i.e., images created via image styles).

I haven't tried any of the more advanced use cases such as all the other modules the project page says it integrates with, but from the code it doesn't look like those would necessarily be broken.

Studira’s picture

The patch has not resolved my issue. Responsive theme creates directory structure within your files folder but never create an image. That's why the 403 error occur. How can I resolve this?

Studira’s picture

FileSize
99.69 KB

The patch has not resolved my issue. Responsive theme creates directory structure within your files folder but never create an image. That's why the 403 error occur. How can I resolve this?

David_Rothstein’s picture

I forgot to mention that #5 requires a cache clear after the patch is applied.

flocondetoile’s picture

Hello

My use case : I insert an image into a field body (full html and ckeditor) with media module (display format is set to grid3 wich is defined on a resp_img style(grid3__mobile).

The image is correctly inserted into the current format (wide). The picture with the style grid3__wide is created. Patch #5 works (before it does not work)

If I resize the browser's windows (normal, narrow, etc..), The image matching styles is not generated. I always have NetworkError 403 Forbidden errors.

I clear the cache

mukesh.yadav’s picture

Hello,

We are not using Responsive images and styles module. We are using the Omega theme for responsiveness and it is failing after upgrading to 7.20. Even, adding $conf['image_allow_insecure_derivatives'] = TRUE; does not work in my case.

Thanks,

David_Rothstein’s picture

@mukesh.yadav, if $conf['image_allow_insecure_derivatives'] = TRUE doesn't make it work again then it's likely a different problem.

Either way, if it relates to Omega rather than the Responsive Images and Styles module, you should create an issue for it in the Omega issue queue, with more details on steps to reproduce. You could add a link to that issue from here though.

attiks’s picture

#9 The patch in #5 will not solve this for inline images, it will probably be easier to upgrade to picture, it will have wysiwyg support pretty soon #1885766: WYSIWYG support

flocondetoile’s picture

@ericaordinary : I've tried resp_img v2.x with Drupal 7.20 without success (with the module media 7.x-1.2 and the 7.x-2.0-unstable7) to insert an image in a node (module ckeditor and ckeditor 3.6.6.1). But this doesn't work : errors NetworkError http 500 (instead of http 403 before with v1.3). But this doesn't work even if i add $conf['image_allow_insecure_derivatives'] = TRUE; in the settings.php. So I guess the problem is from the v2.X of responsive image used with the file display of media module

@attiks : I already use module picture (awesome) for the fields image. But the only solution i found to make responsive image inserted in node was with resp_img v1.3 (with media module for a better UX than IMCE). It seems there is no others solutions with Ckeditor module.

Any ideas ?

amberau79’s picture

@flocondetoile : Likewise, I can't get the 1.x or 2.x versions of this module working with wysiwyg under Drupal 7.20 (with any version of Media). Inserted images are not generated in the appropriate styles. Not ready for picture yet. Would love to see a fix for this but with the 7.x.1 version feature frozen, does this mean no-one is working on one?

David_Rothstein’s picture

If I resize the browser's windows (normal, narrow, etc..), The image matching styles is not generated. I always have NetworkError 403 Forbidden errors.

To clarify, the patch in #5 should work fine for this use case if you have the "Force resize" and "Reload on resize" options both set.

It doesn't work if you're using "Force resize" only though.

flocondetoile’s picture

Hello David,

the option "Reload on resize" is quite heavy and was not set.
So I've tried with it but without success yet. Always errors 403 Forbidden for inserted image.

I'm not a expereinced developper, but may be i can have a look in the code if you can give me some indications ?

attiks’s picture

#13 picture should support both media and imce (using ckeditor) as of yesterday. If you can I would advise you to switch to picture, this is going to be supported for a long time.

resp_img 7.x-1.x was a first attempt at solving this, but it is relying on javascript/jquery/cookies to much, so we started with 7.x-2.x, but this is deprecated by the picture module. Both version will still get bug fixes, but I'm probably not going to add new features/integrations.

flocondetoile’s picture

@attiks

Yes it's certainly the best solution tu use picture for these feature (i wasn't really satisfy to use 2 modules for managing responsives images).

I use Ckeditor 7.x-1.12 module with librarie ckeditor 3.6.6.1 (i plan to migrate to v4.0.1) and media module 7.x-1.2.

I create a custom view mode called "responsive" and associate it in the media file display formatter with a picture group. When i insert an image in a node with modia, i've got a fatal error

Fatal error: Call to undefined function file_entity_file_is_readable() in /var/www/drupal/sites/all/modules/picture/picture.module on line 858

So I update media module to v7.x-2.0-unstable7+25-dev and file entity module to v7.x-2.0-unstable7+37-dev (the last dev version), on a fresh new install of Drupal

I use the latest dev version of pictures and breakpoints.

In Text format > Full HTML i checked Make images responsive with the picture module and
Convert Media tags to markup, and i enabled Plugin for inserting images from Drupal media module in ckeditor module.

I create a custom view mode called "demo" and associate it in the media file display formatter with a picture group. In the file display formatter i have 2 view mode : one (1) with the alt and title field, the other (2) with option "Link image to" and "colorbox group"

With the last view mode (2),
when I insert an image in a body field with plugin media, i can't submit the image (nothing happens)

With the first view mode (1),
when I insert an image in a body field with plugin media, i only have the fallback style of the image in the node.

The render html in the node looks like this

<img class="media-image attr__typeof__foaf:Image img__fid__2 img__view_mode__demo attr__format__demo attr__title__et une arbre pour le titre" typeof="foaf:Image" src="http://drupal.local/sites/default/files/styles/demo_breakpoints_theme_bartik_normal_1x/public/arbre_horizon.jpg?itok=2P-Nxl1-" alt="">

Where i do a mistake ? Or Is it a bug to submit to the issue queue of picture ?

Thanks

David_Rothstein’s picture

FileSize
3.77 KB

Here's a version that works with "Force resize". It uses a bit of an ugly brute force method though.

flocondetoile’s picture

Thanks David

I apply the patch #19 on the dev version 1.x.
I clear the cache

But unfortunately it still not working for me.

I tried with only force resize checked, and both force resize and force reload checked.
Same result.

David_Rothstein’s picture

Hm, it worked for me, and I was using 7.x-1.x dev as well. Anyone else?

jnpwebdeveloper’s picture

FileSize
3.81 KB

Here is a new patch for the 1.3 branch that is based on #19. Using this worked for me.
David, this is similar how I would have approached it. Can you think of a more elegant solution?

David_Rothstein’s picture

Yup, that looks right to me. I guess the code changed a bit between 7.x-1.3 and 7.x-1.x-dev.

Only difference I see is that the (existing) code in 7.x-1.x-dev had a if (typeof orig_src !== 'undefined') check in there as well, which could make sense to add. But I doubt it would matter much in practice.

flocondetoile’s picture

a little clarification : patch #19 or #23 works for me with the image field (with a page reload)

But not for an inline image (inserted in a body field with media module and rendered with a display file wich is associated with a responsive image style) , and it's this use case i have and so tested.

asunko’s picture

FileSize
4.05 KB

Thanks guys. Patch #22 works for me. But I can confirm #24 the patch works only with page reloading.
I added some changes to the patch #22 so image styles are changed depending on screen resolution without page reloading.

Everett Zufelt’s picture

The problem I have with the patch in #25 is the drupal_http_request(). This I assume is to pre-generate images. On a system where for some reason the image is not available, e.g. my local copy of a site where I am too lazy to get a copy of the files on every change to the testing server, the page load can take a crazy amount of time (tested from 24-83 seconds).

This problem likely only exists if:
- There are several to many images
- Drupal cannot generate the images for some reason

I don't think the use-case of image not available in file system is a crazy one. I'm wondering if we could do without that drupal_http_request()?

asunko’s picture

FileSize
4.13 KB

Thanks for testing, Everett Zufelt. This is a very important remark. The following patch doesn't use drupal_http_request() function. I would be very grateful if you test the new patch.

erok415’s picture

Looking forward to a fix for this. I'm using D7.22 and responsive images is broken in Chrome and Safari. However, it works fine in Firefox...weird!

ireneb’s picture

Status: Needs review » Reviewed & tested by the community

I've tested the patch #27, but can't get it working.

Is there any solutions other than downgrading to an earlier core version (if that's possible? - I'm a newbee)

Irene

Olafski’s picture

Irene, as long as the patch doesn't work for you, instead of downgrading to an earlier Drupal version you can allow the current Drupal version to bypass a part of the security check when generating image derivatives. See the D 7.21 release notes and/or the module Image Allow Insecure Derivatives.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs review

The patch in #27 does not apply to the latest 7.x-1.x-dev code (1 hunk fails). I assume that's what we're shooting for here (rather than a direct hotfix against 7.x-1.3?) and if so it can't be committed.

The patch in #19 does still apply to 7.x-1.x-dev. The two patches are actually very similar (but differ in a couple subtle ways)... does anyone understand the differences offhand?

The last I remember, #19 worked everywhere I tested, but there are some reports above that it doesn't work in some cases, such as:

But not for an inline image (inserted in a body field with media module and rendered with a display file wich is associated with a responsive image style) , and it's this use case i have and so tested.

Can anyone else confirm that and/or provide more specific steps to reproduce the problem? If the differences between #19 and #27 were specifically intended to address that, do they work and do they need to be ported to the 7.x-1.x-dev patch also?

attiks’s picture

#29 If you're just starting you are better of switching to the picture module

attiks’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

Old issue, I think you better update to the picture module