0

I have an issue related to drupal image styles, and I am not able to fix it since last two days. Have searched and tried everything on google, but of not help.

I have a drupal instance on production where all the images are stored at imgs/<entity_type>/<entity_id>/<filename>. All these files have three different styles: thumbnail, entity_image, and slide. All the styles were working initially. Now suddenly most of the times styles do not work. If I change the image, most of the time styles show old images, even if at the URL location no image is present. Sometimes, thumbnails are not getting created.

To resolve this, the following are the things I already tried:

  1. drush image-flush: Did not help
  2. Changed permissions of styles to 777: Did not help
  3. Cleared all caches several times: Did not help
  4. Disabled and re-enabled clean URLs: Did not help
  5. Created another instance and tested: Issue persists
  6. Tried to create style forcefully using image_style_url: Did not help
  7. Changed +FollowSymLinks to +SymLinksIfOwnerMatch in .htaccess: Did not help.
  8. Commented Options None and Options +FollowSymLinks in .htaccess: Did not help

Initially it looked like a permission issue but after all this, I am not getting what could be wrong. It could be some issue with inode creation, but not sure. So, please let me know your suggestions, what should be done in this case.

EDIT: I disabled clean URLs and everything worked fine. Enabling clean URLs again gives the same issue. SO it has to do something with the menu I guess, but not sure about the fix. Need a permanent solution as I can not afford to keep clean URLs disabled.

5
  • Does your production environment have more than one server for the sake of performance (or whatever)? If so, do you have a shared file system so that the same images (at the same location) are always available regardless of which server a user or your site happens to be using?
    – bleen
    Jan 9, 2017 at 15:38
  • No, there is only one server on production, hence there is not shared file system. Jan 10, 2017 at 9:53
  • Can you check the response header of images? See if it is responded from server cache.
    – Jimmy Ko
    Jan 10, 2017 at 10:45
  • Same issue for me. I am using responsive module. The fallback image style only gets rendered. Mar 26, 2018 at 10:37
  • 1
    @AnishSheela check my edit 2 in the problem statement, that should work... Mar 27, 2018 at 3:57

1 Answer 1

0

I added following lines in modules/image/image.module, on line 1056 and it started working.

// Create derivated image if it doesn't exist.
  if (!file_exists($file_url) && !file_exists($uri)) {
    if (file_exists($path)) {
      $current_style = image_style_load($style_name);
      image_style_create_derivative($current_style, $path, $uri);
    }
  }

FYI: This change comes with a risk of when Drupal core updates, this will get removed. Also, I found it affected the performance of search in our platform. So, need a permanent solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.