问题:请教如何先把一个图片的某个style图片生成?而不是通过访问触发。我想直接在代码里生成并使用。谢谢!
回答:
子强提供的参考代码:
$image_uri = $value->image[LANGUAGE_NONE][0]['uri']; $style = 'mobile_banner'; $derivative_uri = image_style_path($style, $image_uri); $success = file_exists($derivative_uri) || image_style_create_derivative(image_style_load($style), $image_uri, $derivative_uri); $new_image_url = file_create_url($derivative_uri);
其他参考:
- https://api.drupal.org/api/drupal/modules%21image%21image.module/function/theme_image_style/7.x
- http://tylerfrankenstein.com/code/drupal-7-theme-image-style-example
板块
标签
Drupal 版本