-1

I recently uploaded my site to a live server and the following issue occurs.

When I add an image to a node and check the url from the admin view it all looks fine and the image displays if I open this very url.

http://example.com/sites/default/files/field/image/cocktail.jpg

However when I view these nodes on the site the images don't appear and the url path changes to

http://example.com/sites/default/files/styles/large/public/field/image/cocktail.jpg

I went into the server and manually created this path (it did not exist before) and uploaded the image. Of course it worked, but I can't expect the client to do this.

Why does it look for the image under a different url in production mode?

I was thinking that it's related to Image Styles. In that case why are the styles actually not created automatically?

5
  • Are your directory write rights correctly configured ? Any problem on site's Status Report ?
    – Countzero
    Commented Mar 23, 2012 at 10:31
  • It's usually because of permissions...does your web server user have the correct permissions to write to the sites/default/files folder?
    – Clive
    Commented Mar 23, 2012 at 10:32
  • If not a permissions issue, it may be due to the webserver not passing 404 errors to drupal - this can be an issue in nginx.
    – jvc26
    Commented Mar 23, 2012 at 10:58
  • What is your server stack?
    – jvc26
    Commented Mar 23, 2012 at 16:47
  • Status Report is giving me the following. Seems relevant. "Upload progress Not enabled Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the PECL uploadprogress library (preferred) or to install APC."
    – user6367
    Commented Mar 24, 2012 at 14:44

3 Answers 3

2

I get exactly the same problem :
(drupal 7.12 + I use symlinks to a shared code base)

When creating a blog article with an image, the image didn't show up. I check the upload : The image gets uploaded into :
sites/default/files/field/image/Bienvenue.jpg
whereas the link points to :
sites/default/files/styles/large/public/field/image/Bienvenue.jpg and there was no image at that location...

I double checked permissions which seemed fine (drupal runs as user and apache does perform a suPHP).
However :
I switched permissions to 777 for folder default and all below (except you must not chmod 777 your settings.php file -- for security reason)
and then, after viewing the blog article, the jpg file showed up into : sites/default/files/styles/large/public/field/image/Bienvenue.jpg.

I conclude from that :
a) Actually files for displaying images (the ones in default/files/styles/xxx) are created when first needed
b) permission requested to create these images go beyond 700

I did the test again : permissions 700 and 755 => image uploaded, but not displayed permissions have to be 777 to be displayed

Hope it can help you, although it does not explain this permission stuff.
(
i mean : drupal gets enough permissions with 700 for creating in : sites/default/files/field/image/
but these same permissions are unsufficient for writing into :
sites/default/files/styles/large/public/field/image/
)

0

I'm getting something very similar in my Dev environment.

I have just added the following code to my template:

<?php if(isset($node->field_image['und'])) {
$img = array(
'path' => $node->field_image['und'][0]['uri'],
'width' => '',
'height' => '',
'alt' => $node->field_image['und'][0]['alt'],
'title' => $node->field_image['und'][0]['title'],
);
print theme('image_style', $img);
} ?>

Devel indicates that $node->field_image['und'][0]['uri'] contains

public://projects/8xbayshorebus.jpg

and the public path for the site is

/sites/default/files

as one might expect.

This is rendering as

src="http://[site]/sites/default/files/styles//public/projects/8xbayshorebus.jpg?itok=[token]"

where I expect:

src="http://[site]/sites/default/files/projects/8xbayshorebus.jpg?itok=[token]"

I have confirmed that http://[site]/sites/default/files/projects/8xbayshorebus.jpg exists.

Any idea why this might be happening? (Drupal 7.24)

I copied this code from another content type.

Oddly, that content type is working fine for http but not for https.

0

I know this is old but i got this problem when i was doing a tutorial exercise to build an Article in Drupal 8.

It occurred to me that what happens is that your uploaded image goes to the designated directory OK but the 'thumbnail' and 'large' versions are generated on the fly, by Drupal, within the Drupal_root/sites/default/files/styles directory. This act of creation happens the first time they are required.
On my system, Drupal uses the user account "www-data", so that account needs write access to the styles directory to let it create files and directories.

After making that change (chmod), my uploaded image appeared, viola!

Your Answer

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

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