[wordpress插件] Custom Image Sizes自定义图像尺寸

wordpress 插件 文章 2020-04-08 11:40 534 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

Custom Image Sizes is a WordPress plugin that

自定义图像大小是一个WordPress插件,

    • generates the correctly-sized version of an image’s thumbnail, if it doesn’t already exist.
    • 生成正确大小的图像缩略图(如果尚不存在)。

    • lets you specify custom sizes with a size parameter of '[width]x[height]'.
    • 让您指定尺寸为'[width] x [height]'的自定义尺寸。

    Read more at the Custom Image Sizes page.

    自定义图像尺寸页面上了解更多。

    p>

    >

    Usage

    用法

    The typical WordPress way

    典型的WordPress方式

      • Put add_image_size( 'my_custom_thumbnail_name', 220, 130, true ); in your theme’s functions.php file.
      • add_image_size('my_custom_thumbnail_name',220,130,true); 放入主题的functions.php文件中。

      • Add the code to display that attachment’s thumbnail where you want it to appear: echo wp_get_attachment_image($attachment_id, 'my_custom_thumbnail_name');
      • 添加代码以将附件的缩略图显示在您希望显示的位置: echo wp_get_attachment_image($ attachment_id,'my_custom_thumbnail_name');

      • Unlike WordPress by itself, Custom Image Sizes will generate the thumbnail for an image, even if the image was uploaded before this add_image_size() was set.
      • 与WordPress本身不同,即使在设置 add_image_size()之前上传图片,“自定义图片大小”也会生成图片的缩略图。

      A more direct Custom Image Sizes way

      更直接的“自定义图像尺寸”方式

        • Call wp_get_attachment_image_src() or wp_get_attachment_image() with the desired thumbnail '[width]x[height]' dimensions, like so:

          用所需的缩略图'[width] x [height]'尺寸调用 wp_get_attachment_image_src() wp_get_attachment_image(),如下所示:

            echo wp_get_attachment_image($attachment_id, '220x80');  

            echo wp_get_attachment_image($ attachment_id,'220x80');  

          /**   

          / **   

          * The above prints markup like   

          *以上打印标记   

          *

          * “”   <p/

          * class="attachment-220x80" src="http://www.example.com/path-to-file/something-220x80.jpg" />   

          * class =“ attachment-220x80” src =“ http://www.example.com/path-to-file/something-220x80.jpg” />   

          */

          * /

安装步骤

    1. Upload filosofo-custom-image-sizes/ to the /wp-content/plugins/ directory
    2. filosofo-custom-image-sizes / 上载到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

下载地址
https://downloads.wordpress.org/plugin/custom-image-sizes.1.0.zip
-EOF-

AI助手支持GPT4.0