[wordpress插件] Category Image(s)类别图片

wordpress 插件 文章 2020-03-18 10:10 523 0 全屏看文

AI助手支持GPT4.0

评分
90
描述

Display an image for each category associated with a post.

显示与帖子相关的每个类别的图像。

Notes:

注意:

This plugin provides the templates tag c2c_the_category_image() which basically reproduces and extends the functionality of WordPress's core function the_category() to add the ability to display a category image instead

此插件提供了模板标签 c2c_the_category_image(),该标签基本上复制并扩展了WordPress核心功能 the_category()的功能,从而增加了显示类别图像的功能

of the category name in the link to the category archive.

类别档案链接中类别名称的名称。

With its $image_extensions argument defaulted to "", the plugin could be a drop-in replacement for the_category().

由于其$ image_extensions参数默认为“” ,因此该插件可以代替 the_category()

As is done in the_category(), the image or text for each category is also a link back to that category’s archive.

就像 the_category()中所做的那样,每个类别的图像或文本也是指向该类别存档的链接。

Related info about the function:

有关该功能的相关信息:

    • If $image_extensions is defined, but no image is found for the category, then nothing is displayed for that category.
    • 如果定义了$ image_extensions,但未找到该类别的图像,则该类别将不显示任何内容。

    • $image_extensions can be defined as a space separated list of image extensions.

    • $ image_extensions可以定义为以空格分隔的图像扩展名列表。

      Files will be checked with the image extensions in the order those extensions were provided;

      将按照提供的图像扩展名的顺序检查文件的扩展名;

      default is ‘png gif jpg’.

    • 默认值为“ png gif jpg”。

    • The number of category links/images displayed can be limited via the $limit argument
    • 可以通过$ limit参数限制显示的类别链接/图像的数量

    • Category image tags are defined with class=”catimage” for stylesheet manipulation.
    • 使用class =“ catimage”定义类别图像标签以进行样式表操作。

    • The result can be filtered via the filter named “c2c_the_category_image”.
    • 可以通过名为“ c2c_the_category_image”的过滤器过滤结果。

    • Must be run inside “the loop”.

      必须在“循环”中运行。

      c2c_get_category_image_list() is another provided function, which is identical to c2c_the_category_image() except that it doesn’t echo the result.

      c2c_get_category_image_list()是另一个提供的函数,与 c2c_the_category_image()相同,只是它不回显结果。

    Links: Plugin Homepage |

    链接:插件主页 |

    Plugin Directory Page |

    插件目录页面 |

    Author Homepage

    作者主页

    Template Tags

    模板标签

    The plugin provides one optional template tag for use in your theme templates.

    该插件提供了一个可选的模板标签,供您在主题模板中使用。

    Functions

    功能

      • <?php函数c2c_the_category_image($ seperator ='',$ parents ='',$ image_extensions ='png gif jpg',$ image_dir ='/ wp-content / images /',$ use_name_if_no_image = false

        , $start_from='begin', $limit=999 ) ?>

      • ,$ start_from ='开始',$ limit = 999)吗?>

      This displays the image associated with a post’s categories.

      这将显示与帖子类别相关的图像。

      Arguments

      参数

        • $separator

          $ separator

          Optional argument.

          可选参数。

          The text and/or HTML to appear between each of a post’s category images.

          在每个帖子的类别图片之间显示的文本和/或HTML。

        • $parents

          $ parents

          Optional argument.

          可选参数。

          Allows you to specify if you want ancestor categories of a post’s category to be imaged and linked as well.

          允许您指定是否也要显示和链接帖子类别的祖先类别。

          Valid options are ‘multiple’, ‘single’, and ”.

          有效选项是“多个”,“单个”和“”。

          Default is ”.

          默认值为“。

        • $image_extensions

          $ image_extensions

          Optional argument.

          可选参数。

          A space-separated list of image extensions (case insensitive).

          以空格分隔的图像扩展列表(不区分大小写)。

          If defined as ” then no image is retrieved and the category name is displayed instead (a la the_category()).

          如果定义为“”,则不会检索任何图像,而是显示类别名称(la the_category())。

          Default is ‘png gif jpg’.

          默认值为“ png gif jpg”。

        • $image_dir

          $ image_dir

          Optional argument.

          可选参数。

          The directory in which the category image(s) reside.

          类别图像所在的目录。

          The value should be a location relative to the main URL of your blog.

          该值应该是相对于博客主URL的位置。

          Default is ‘/wp-content/images/’

          默认值为“ / wp-content / images /”

        • $use_name_if_no_image

          $ use_name_if_no_image

          Optional argument.

          可选参数。

          Boolean value (true or false) indicating if the name of the category should be displayed for each category that does not have an associated image.

          布尔值(真或假),指示是否应为没有关联图像的每个类别显示类别名称。

          Default is false.

          默认值为false。

        • $start_from

          $ start_from

          Optional argument.

          可选参数。

          How to traverse the list of post’s categories;

          如何遍历帖子类别列表;

          either ‘begin’ or ‘end’.

          “开始”或“结束”。

          Default is ‘begin’

          默认值为“开始”

        • $limit

          $ limit

          Optional argument.

          可选参数。

          The maximum number of category images to be displayed.

          要显示的类别图像的最大数量。

          Default is 999 (basically, no limit)

          默认值为999(基本上没有限制)

        • $post_id

          $ post_id

          Optional argument.

          可选参数。

          The Post ID.

          帖子ID。

          If false, then use the current post (i.e. while in the loop).

          如果为false,请使用当前帖子(例如,在循环中)。

          Default is false.

          默认值为false。

        Examples

        示例

          • You can opt to treat only certain categories as having a graphical representation by defining an image for them but not creating images for the non-graphically represented categories (as in you can have a subset of categories that dictate what image to be displayed

            通过为特定类别定义图像,您可以选择仅将某些类别视为具有图形表示形式,而不是为非图形表示类别创建图像(因为您可以使用类别的子集来决定要显示的图像

            for the post).

            的帖子)。

          • You can take advantage of the $image_extension and/or $image_dir arguments to display different category icons under different contexts, i.e. if showing a $single post, choose to use a ‘png’ image, otherwise use ‘gif’;

            您可以利用$ image_extension和/或$ image_dir参数在不同的上下文中显示不同的类别图标,即,如果显示$ single帖子,则选择使用“ png”图像,否则使用“ gif”;

            or locate your images in different directories '/wp-content/images/cat-images/small/' and '/wp-content/images/cat-images/large/' and decide based on context where to get the image(s

            或将您的图片放在不同的目录“ / wp-content / images / cat-images / small /”和“ / wp-content / images / cat-images / large /”中,然后根据上下文决定从何处获取图片

            ) from:

            ),来自:

            // In showing the post singularly, then use a larger image, else use a small image
              

            //在单数显示帖子时,然后使用较大的图像,否则使用较小的图像
              

            if ( is_single() ) {
                

            if(is_single()){
                

            c2c_the_category_image(”, ”, ‘gif’, ‘/wp-content/images/cat-images/large/’);
              

            c2c_the_category_image(”,“”,“ gif”,“ / wp-content / images / cat-images / large /”);
              

            } else {
                

            } else {
                

            c2c_the_category_image(”, ”, ‘gif’, ‘/wp-content/images/cat-images/small/’);
              

            c2c_the_category_image(”,“”,“ gif”,“ / wp-content / images / cat-images / small /”);
              

            }

            }

          • Show all images in a comma-separated line:

            以逗号分隔的行显示所有图像:

          • Show all images in an unordered list:

            以无序列表显示所有图像:

          • Assuming one category per post, just show the category image without further HTML markup:

            假设每个帖子一个类别,只需显示类别图片即可,无需进一步的HTML标记:

            < ?php c2c_the_category_image(' ');

            <?php c2c_the_category_image('');

            // note the space in the argument, necessary to turn off default

            //注意参数中的空格,这是关闭默认值所必需的

              markups ?>

                标记?>

                Filters

                过滤器

                The plugin exposes two filters and one action for hooking.

                该插件提供了两个过滤器和一个用于挂接的动作。

                Typically, customizations utilizing these hooks would be put into your active theme’s functions.php file, or used by another plugin.

                通常,利用这些钩子进行的自定义将被放入活动主题的functions.php文件中,或由另一个插件使用。

              c2c_get_category_image (filter)

              c2c_get_category_image(过滤器)

              The 'c2c_get_category_image' hook allows you to use an alternative approach to safely invoke c2c_get_category_image() in such a way that if the plugin were deactivated or deleted, then your calls to the function won't

              通过“ c2c_get_category_image”钩子,您可以使用另一种方法安全地调用 c2c_get_category_image(),这样,如果停用或删除了插件,则对函数的调用不会

              cause errors in your site.

              导致您的网站出现错误。

              Arguments:

              参数:

                • same as for c2c_get_category_image()
                • c2c_get_category_image() 相同

                Example:

                示例:

                Instead of:

                代替:

                    

                  <?php $ cat_images = c2c_get_category_image($ cat); 

                ?>

                ?>

                Do:

                做:

                    

                  <?php $ cat_images = apply_filters('c2c_get_category_image',$ cat); 

                ?>

                ?>

                c2c_get_the_category_image_list (filter)

                c2c_get_the_category_image_list(过滤器)

                The 'c2c_get_the_category_image_list' hook allows you to use an alternative approach to safely invoke c2c_get_the_category_image_list() in such a way that if the plugin were deactivated or deleted, then your calls to the function won't

                通过“ c2c_get_the_category_image_list”钩子,您可以使用另一种方法安全地调用 c2c_get_the_category_image_list(),这样,如果停用或删除了插件,则对函数的调用不会

                cause errors in your site.

                导致您的网站出现错误。

                Arguments:

                参数:

                  • same as for c2c_get_the_category_image_list()
                  • c2c_get_the_category_image_list() 相同

                  Example:

                  示例:

                  Instead of:

                  代替:

                      

                    <?php $ cat_list = c2c_get_the_category_image_list(); 

                  ?>

                  ?>

                  Do:

                  做:

                      

                    <?php $ cat_list = apply_filters('c2c_get_the_category_image_list',''); 

                  ?>

                  ?>

                  c2c_the_category_image (action)

                  c2c_the_category_image(操作)

                  The 'c2c_the_category_image' hook allows you to use an alternative approach to safely invoke c2c_the_category_image() in such a way that if the plugin were deactivated or deleted, then your calls to the function won't

                  通过'c2c_the_category_image'钩子,您可以使用另一种方法安全地调用 c2c_the_category_image(),这样,如果停用或删除了插件,则对函数的调用不会

                  cause errors in your site.

                  导致您的网站出现错误。

                  Arguments:

                  参数:

                    • same as for c2c_the_category_image()
                    • c2c_the_category_image()

                    Example:

                    示例:

                    Instead of:

                    代替:

                        

                      <?php c2c_the_category_image(); 

                    ?>

                    ?>

                    Do:

                    做:

                        

                      <?php do_action('c2c_the_category_image'); 

                    ?>

                    ?>

安装步骤

    1. Unzip category-images.zip inside the /wp-content/plugins/ directory (or install via the built-in WordPress plugin installer)
    2. / wp-content / plugins / 目录中的 category-images.zip 解压缩(或通过内置的WordPress插件安装程序安装)

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

    5. Create category image (.png unless you specify the extension in your call to c2c_the_category_image()) for each category you wish to have an image for, placing the image into the wp-content/images

    6. 为每个要为其创建图像的类别创建类别图像(.png,除非您在调用 c2c_the_category_image()中指定扩展名),然后将图像放入wp-content / images

      / directory (unless you specify another location in your call to c2c_the_category_image()).

      /目录(除非您在调用 c2c_the_category_image()的过程中指定其他位置)。

      Remember to give the filename the nice-name version of the category name.

    7. 请记住为文件名提供类别名称的好听的版本。

    8. Make use of the c2c_the_category_image() template function in your template (see examples below).
    9. 在模板中使用 c2c_the_category_image()模板函数(请参见下面的示例)。

下载地址
https://downloads.wordpress.org/plugin/category-images.1.7.3.zip
-EOF-

AI助手支持GPT4.0