【问题标题】:How to Remove Image Resizing in HTML如何在 HTML 中删除图像大小调整
【发布时间】:2014-08-11 19:56:29
【问题描述】:

我不确定该网站是否通过 HTML 重新调整图像大小,或者图像大小是否自动添加到代码中。

如果要调整图像大小,则需要修复此问题,因为它会减慢页面加载时间。

这是example page

【问题讨论】:

    标签: php drupal drupal-7 image-resizing drupal-theming


    【解决方案1】:

    您需要覆盖默认的theme_image 并删除widthheight 属性,或者将它们的值设置为auto

    例子:

    // In your theme's template.php file
    function [YOUR_THEME]_image($variables) {
      $attributes = $variables['attributes'];
      $attributes['src'] = file_create_url($variables['path']);
    
      foreach (array('alt', 'title') as $key) {
        if (isset($variables[$key])) {
          $attributes[$key] = $variables[$key];
        }
      }
    
      return '<img' . drupal_attributes($attributes) . ' />';
    }
    

    【讨论】:

    • 好的,你是说通过 html 调整大小?
    • 不,这不是我要说的:)。你问了How to Remove Image Resizing in HTML,答案解释了如何。但是为了创建图像样式预设,您应该从?q=admin/config/media/image-styles 开始。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-26
    • 1970-01-01
    • 2022-01-14
    • 2020-09-11
    • 2017-06-21
    相关资源
    最近更新 更多