Search code examples
drupaldrupal-7

Drupal 7: Applying an Image Style to a Picture


I have a folder with pictures that do not belong to Drupal 7, I want to use the mechanism of Drupal 7 to apply certain styles to the picture knowing only its address, something like this:

$uri = '/sites/defalut/files/images/my_image.jpg';
$style = 'machine_name_style';
$styleFileName = drupal_realpath(image_style_path($style, $uri));
if (!file_exists($styleFileName)){
    $image_style = image_style_path($style, $uri);
    image_style_create_derivative(image_style_load($style), $uri, $image_style);
}

but this code dont working - how apply image style by absolute image path ?


Solution

  • What about:

    theme('image_style',array('style_name' => 'thumbnail', 'path' => '/sites/default/files/images/my_image.jpg'));