0
<img class="lazy" title="Windows 8" alt="Windows 8" src="http://b.a.org/sites/default/files/styles/thumbnail/public/category_pictures/Windows%20Media%20Player%20alt.png?itok=NXy-3w5_" href="lazy" data-original="http://b.a.org/sites/default/files/styles/thumbnail/public/category_pictures/Windows%20Media%20Player%20alt.png?itok=NXy-3w5_">

我想调整 src 以便它可以显示“/sites/all/themes/s5/images/blank.jpg”而不是图像网址。你能帮我修改我在 Drupal 7 的 template.php 中使用的以下代码来实现这一点吗?

function s5_preprocess_image(&$variables) {
 if ($variables['style_name'] == 'thumbnail') {
     $variables['attributes']['class'][] = 'lazy';
     $variables['attributes']['data-original'][] = file_create_url($variables['path']);
}}

非常感谢!!

4

1 回答 1

1

在“if”块的底部添加了一行:

function s5_preprocess_image(&$variables) {
   if ($variables['style_name'] == 'thumbnail') {
       $variables['attributes']['class'][] = 'lazy';
       $variables['attributes']['data-original'][] = file_create_url($variables['path']);
       $variables['path'] = '/sites/all/themes/s5/images/blank.jpg';
   }
}
于 2013-05-21T02:47:30.897 回答