5

Warning: Division by zero in theme_image_style_preview() (line 804 of /var/www/html/modules/image/image.admin.inc).

Warning: array_intersect_key(): Argument #1 is not an array in theme_image_style_preview() (line 806 of /var/www/html/modules/image/image.admin.inc).

I am receiving the above errors when I view several of the "stock" image styles on my site. I just moved my site from a development server to a production server, and the error does not occur on the development server version. I checked the directory permissions on the production server, and they appear to be consistent with the development server's permissions.

One really strange thing occurs when I view the source on the "preview image" in the admin back-end of one of those styles that has the issue. When I do, it shows the following path being called (which is, of course, not a valid path):

http://mysite.com/sites/default/files/styles/large/public/modules/image/sample.png?cache_bypass=1399676683

The "sites/default/files/styles/large/public/" part seems to be part of the issue, but I am not sure how that got there. All of my custom image styles work fine.

Thanks!

  • 1
    Have a look at theme_image_style_preview source. Your error comes from a missing sample image or failure to generate a derivative image from that. – David Thomas May 11 '14 at 23:17
  • @DavidThomas why not to post that as an answer? – Mołot May 12 '14 at 6:46
  • @David Thomas, that does not seem to be the source of the issue. When I change the code referencing "theme_image_style_preview" in image.admin.inc, that seems to control the "original" image... not the "preview" image for the image style I am editing. – hockey2112 May 12 '14 at 14:29
3

I did:

chmod 777 drupal/sites/example.com/files/styles

and the error went away and my drupal 7 new image-style worked.

5

Apparently it is not safe to chmod files to 777.

A preferred way is to chmod files to 644, directories to 755 and set the ownership to the webserver, so the webserver can write files.

Here's a script for Ubuntu:

# Change directory permissions to 755.
find sites/default/files -type d -exec chmod 755 {} +
# Change folder permissions to 644.
find sites/default/files -type f -exec chmod 644 {} +
# Set ownership to webserver.
chown -R www-data:www-data sites/default/files

Learn more on - Recommended directory permissions.

  • This should be the accepted answer as setting the files directory permissions to 777 is not a good answer. – DrCord Jun 3 '16 at 17:40

protected by Community Jun 2 '15 at 18:05

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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