Hi,

after uploading an image, I can insert it into the text field via the "insert" button. However, when I select a style from "Presets for Show", the blue question mark appears instead of the image. Looking into the image folder (from what the url says), there is no image. I assume there is no image created in the styles folders.

I can't find out why this is. Any help appreciated.

pap.

Comments

hutch’s picture

Image presets are handled by the image module which creates the presets on the fly in the files/styles folder. If they are not created on demand then there is either a problem in the image module setup or the file permissions in files/styles/ does not allow the creation of images. All Imagepicker does is leverage the features provided by the Image module.

fras42’s picture

I have the same issue. Check the watchdog for the last messages, I've found access denied inspite off all the file permissions were correct. After some googling (access denied + image_style_url) , It started working after I put $conf['image_allow_insecure_derivatives'] = TRUE; in settings.php, however I don't understand too much what it does.

hutch’s picture

There are some comments in /modules/image.module around line 811 and on, these explain the need for a token.
I have just tested a copy of imagepicker, enabled the use of presets and inserted a preset "medium" and it has a token in the url, eg something like

<img src="http://mysite.com/sites/default/files/styles/medium/public/imagepicker/1/34.jpg?itok=P2-JQUV_" alt="Image" class="imgp_img" />

The image exists (once I access it in the browser) and displays correctly.

So check that Imagepicker is providing a token when inserting the image URL (it probably is) and if the token is still there when viewing the image in the saved content. If the token has disappeared then someting is filtering so you need to check your html filters and/or content filters.

brianlp’s picture

Thanks both for the hints. Tokens are being generated and are in the image url when viewing the content, that doesn't seem to be the problem.

Adding $conf['image_allow_insecure_derivatives'] = TRUE; to settings.php makes everything work as expected. However, in the comments of image.module around line 811 it says "this will increase the site's vulnerability to denial-of-service attacks" due to bypassing the tokens.

– Before setting TRUE, no images existed in files folder like for example: /sites/default/files/styles/large/public/imagepicker/1/my_image.jpg

– After setting TRUE, those images do exist and are displayed properly.

Once the images are generated, I can remove that line of code from settings.php and it will remain working. So essentially this is only needed for the process of generating the images and placing them in the respective folder.

Also, if you apply that line of code to settings.php, all images of previously saved content with the blue question mark will be generated then.

I don't know much about what's going on under the hood here so atm I have not idea how to solve that. I would be happy if there was a way without using that snippet in settings.php.

fras42’s picture

I installed the dev version of Imagepicker and it works with image style presets without allowing insecure derivatives in settings.php.

hutch’s picture

Yes, I checked the CHANGELOG and there was a fix for presets, this was to allow for the enhanced security measures mentioned in image.module.
I have issued a new stable version, imagepicker-7.x-1.8, this brings stable up to dev.

brianlp’s picture

Works fine, thanks!

brianlp’s picture

Status: Active » Closed (fixed)