3

This question already has an answer here:

I need to create and apply image style based on the height and width provided by user. So what I did is, I created image style using Drupal core UI (http://mysite.com/admin/config/media/image-styles/add). I also added scale effect to it. After that I can see the style directory created under [path]/sites/default/files/styles/mystyle

Now programmatically I updated the effect (width and height) and flushed the image style. But after executing my code, its removing the created style directory (mystyle) and nothing happening.

My Code:

$style = image_style_load('mystyle');

$isid = $style['isid'];

db_delete('image_effects') //deleting existing effect
    ->condition('isid', $isid, '=')
    ->execute();    

$effect = array(            // creating new effect
        'name' => 'image_scale',
        'data' => array(
                'width' => $width,
                'height' => $height,
                'upscale' => FALSE,
        ),
        'isid' => $isid,
);
image_effect_save($effect);

$output = image_style_url('mystyle', $uri);

image_style_flush($style);  

I'm getting Drupal access denied page when I try to access the return value of image_style_url. what am I missing?

marked as duplicate by Clive Sep 27 '13 at 12:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.