drupal - 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 ?
解决方案
关于什么:
theme('image_style',array('style_name' => 'thumbnail', 'path' => '/sites/default/files/images/my_image.jpg'));
推荐阅读
- c# - 执行超时如何优化此 kata 以更快地运行?
- c++ - 如何使用 std::vector
使用 Vulkan 映射内存时,而不是 void**? - php - 未捕获的错误:调用未定义的函数 sanitize()
- angular - 在抽象类中实例化 HttpClient 对象
- python - 在 python 中设置许多变量的最干净的方法
- python - Pandas 日期时间减法 - 分配 nan 值
- javascript - JavaScript 正则表达式捕获模式中的字符串并将其替换为新字符串,但仅适用于特定行
- c++ - 尝试编译类实现时对“winmain”的未定义引用
- python - 当使用 Pytorch 的偏差完好无损时,如何仅操纵神经网络的权重?
- javascript - JSON在js中给出了奇怪的格式结果,我怎样才能访问数据?