0

I want to apply an image style to an image and use it via CSS:

if (isset($node->field_images_image['und'][0]['filename'])) $vars['blurred_background'] = image_style_url('background_blurred', 'assets/'.$node->field_images_image['und'][0]['filename']);

In my page.tpl.php:

<?php if (isset($blurred_background)): ?>
<style type="text/css">
body {
    background: url(<?php print $blurred_background; ?>) no-repeat center 0 #292929;
}
</style>
<?php endif; ?>

which actually prints a url like:

body {
    background: url(http://localhost:8888/projectname/assets/styles/background_blurred/public/assets/2222.jpg?itok=xqy5lL55) no-repeat center 0 #292929;
}

But the image is not visible (and not created in the file directory) and if I open the image url, I get an access denied, although there is a token appended?!

I guess this has to do with Drupal's 7.20 security update which I originally dont want to disable. Is there no correct way of doing this without disabling this security feature?

  • Have you tried disabling the image token feature to see if that is the problem? There is a potential problem which you may see if your images were generated using devel_generate, for example. (I reported this issue, so I know it quite well :) – Alfred Armstrong Apr 2 '13 at 11:01
  • adding $conf['image_allow_insecure_derivatives'] = TRUE; solves this issue.. :( – Alex Apr 2 '13 at 11:07
  • Upgrading to the latest version of Drupal i.e. 7.21 might help as per its release notes. – AjitS Apr 2 '13 at 11:27
  • of course i am using the most recent version... – Alex Apr 2 '13 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.