首页 > 解决方案 > 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 ?

标签: drupaldrupal-7

解决方案


关于什么:

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

推荐阅读