How to call and display the thumbnail or cover image of AnQiCMS template, what processing methods are supported?

Calendar 👁️ 82

In website content operation, images play a vital role, not only attracting users' attention and enhancing the beauty of the page, but also an indispensable part of search engine optimization (SEO).AnQiCMS provides flexible and diverse mechanisms for handling and displaying thumbnails or cover images of articles, categories, single pages, etc. Whether it is automated processing in the background or fine control at the template level, it can meet all kinds of content operation needs.

Image source and background intelligent processing

When using AnQiCMS to publish content, the source of content images and preliminary processing are mainly concentrated in the background:

first, Image sourceExtremely flexible. When editing articles, categories, single pages, or tags, we usually manually upload or select an image from the existing image library in the 'Document Image' or 'Thumbnail' field as the cover.A very practical feature is that even if you do not manually specify a thumbnail, AnQiCMS will intelligently extract the first image from the article content as the thumbnail for the content, which greatly saves time for operation personnel.In addition, for categories and single pages, you can also set the "Banner Image" field, which supports uploading multiple images for carousel display. This is very useful when creating visually impactful pages.

Secondly, AnQiCMS isContent settingsIt provides powerful image automation processing capabilities, which directly affects the display and loading performance of images on the front end. These processing methods include:

  • Remote image download and WebP conversionYou can choose whether to download the external images referenced in the article to your local machine, which helps to unify the management of image resources and avoid the failure of external links.At the same time, the system also supports automatically converting uploaded JPG, PNG, and other format images to WebP format. WebP usually provides better compression, thereby speeding up page loading speed.
  • Automatically Compress Large ImageTo avoid the original large image from affecting the website performance, you can enable the automatic compression feature and set a maximum width.The system will automatically compress the image to the specified size during upload, reducing file size.
  • Thumbnail Processing MethodThis is a highlight of AnQiCMS in image processing, it provides three fine thumbnail generation strategies:
    • Scale proportionally to the longest sideThis method will display all the content of the image, maintaining the original image ratio, but the size of the thumbnail may not be consistent.
    • Fill the longest side: If you need a fixed-size thumbnail while also displaying the entire image content, this option will be very useful.The image will be centered on the canvas of the specified size, and the insufficient part will be filled with white.
    • Trim according to the shortest edgeThis method is suitable for scenarios where the main subject of the image needs to be highlighted and strict size requirements are needed. The image will be cropped centrally and may lose some edge information.
  • Thumbnail size and default thumbnailYou can set a uniform thumbnail size according to the actual needs of the front-end template.In addition, AnQiCMS also allows you to set a default thumbnail, which the system will automatically use for display when a piece of content does not specify a thumbnail, ensuring the consistency of website image display.

These backend settings are global and can provide unified, automated management and optimization for website image resources.

Image calling and fine control in templates

AnQiCMS uses a syntax similar to Django template engine, variables are enclosed in double curly braces{{变量}}Logic control uses{% 标签 %}The variable name usually follows camel case naming, which brings great convenience to template development.In the template, we can call and display the thumbnails or cover images of articles, categories, single pages, and tags in multiple ways.

1. Call the image field of articles, categories, and single pages

Whether it is an article detail page or a list page, we can obtain the image field through corresponding tags (such asarchiveDetail/archiveList/categoryDetail/pageDetailetc) to get the image field:

  • Logo: It usually refers to the cover main image or large image with relatively high resolution.
  • Thumb: Refers to the thumbnail automatically generated by the system according to the backend settings.
  • Images: For some content models (such as articles, single pages, categories), group photo upload may be supported.ImagesThe field will return an array of image URLs.

For example, on an article detail page, you can call the article's thumbnail and cover image like this:

{# 默认获取当前文章的封面首图 #}
<img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />

{# 默认获取当前文章的缩略图 #}
<img src="{% archiveDetail with name="Thumb" %}" alt="{% archiveDetail with name="Title" %}" />

{# 调用指定 ID 文章的缩略图 #}
<img src="{% archiveDetail with name="Thumb" id="123" %}" alt="{% archiveDetail with name="Title" id="123" %}" />

If the content model supports multi-image upload (such as theImagesfield), you can display all images by looping:

{# 假设 archiveImages 变量包含了文章的 Images 数组 #}
{% archiveDetail archiveImages with name="Images" %}
<div class="article-gallery">
    {% for imgUrl in archiveImages %}
        <img src="{{ imgUrl }}" alt="文章图片" />
    {% endfor %}
</div>

On the article list page, you canarchiveListEasily call the image of each article in the loop:

{% archiveList articles with type="list" limit="10" %}
    {% for item in articles %}
        <div class="article-item">
            <a href="{{ item.Link }}">
                {# 调用列表项的缩略图 #}
                {% if item.Thumb %}
                    <img src="{{ item.Thumb }}" alt="{{ item.Title }}" />
                {% endif %}
                <h3>{{ item.Title }}</h3>
            </a>
        </div>
    {% endfor %}
{% endarchiveList %}

The way to call images for categories, single pages, and tags is similar to that of articles, just replace the corresponding tags, for example:categoryDetailTo get the image details of the category, pageDetailGet a single page image,tagDetailGet a tag image.

2. UsethumbThe filter performs flexible image processing

In addition to direct callingLogoorThumbIn addition to obtaining the background pre-processed image, AnQiCMS also provides a powerful feature,thumbFilter, allows you to apply at the template layer toany image URLPerform real-time thumbnail generation and size adjustment. This means that even if you have set a uniform thumbnail in the background, in specific scenarios on the front end, you can easily obtain thumbnails of different sizes or processing methods.

thumbThe basic usage of the filter is{{ image_url|thumb }}. It will generate a processed thumbnail by combining the original image address with the AnQiCMS image processing engine.

For example, you want the thumbnail of the article to be displayed as 200x150 pixels (shortest side cropped), even though the default is a 300x200 pixel aspect ratio image generated by the backend:

{# 假设 item.Logo 是原始图片 URL #}
<img src="{{ item.Logo|thumb:200,150,'裁剪' }}" alt="{{ item.Title }}" />

Herethumb:200,150,'裁剪'Indicates: Set the image width to 200px, height to 150px, and use 'shortest side cropping' mode.This flexibility allows the front-end design to customize the image display completely according to the layout requirements.

**

Related articles

How to use the pseudo-static feature of AnQiCMS to optimize the URL structure to improve the crawling and display effect of search engines?

## Utilizing AnQiCMS's SEO-friendly URL structure: A practical guide to improving search engine crawling and display effectiveness in the digital marketing wave In today's digital marketing wave, Search Engine Optimization (SEO) has become one of the key factors for website success.A clear, friendly, and semantically rich URL structure is undoubtedly the cornerstone of improving a website's SEO performance.It not only helps search engines crawl and understand your content more efficiently, but also significantly improves the reading experience and memorability of users.

2025-11-09

How to implement multi-language content switching and display for AnQiCMS to serve global users?

Under the wave of global digitalization, your website can communicate seamlessly with users worldwide in multiple languages, which is no longer a luxury but a key step to expanding the international market and enhancing brand influence.AnQiCMS (AnQi CMS) was born to meet such needs, it provides a flexible and efficient solution that makes the switching and display of multilingual content simple and powerful. ### How to build a multilingual content system in AnQiCMS?

2025-11-09

How to configure unique display fields for different content models in AnQiCMS to adapt to personalized content display?

In AnQi CMS, it is a crucial function to configure unique display fields for different content models to meet the diverse needs of website content display.This capability allows us to flexibly customize the structure of articles, products, activities, or any other type of content based on specific business requirements, thereby providing a highly personalized content display experience.Understanding Content Model: The Foundation of Personalized Display One of the core advantages of AnQiCMS is its 'flexible content model'.

2025-11-09

What methods does AnQiCMS support to accurately control the display of keywords and descriptions of website content in search results?

In today's highly competitive online environment, making website content stand out in search engines is a focus for every operator.Precisely controlling the keywords and descriptions of website content is a key strategy to improve search visibility, attract target users, and optimize click-through rates.AnQiCMS as an enterprise-level content management system provides multi-dimensional, in-depth functional support, allowing you to flexibly and meticulously manage the SEO performance of your website.

2025-11-09

How to configure the pagination display style of the content list in AnQiCMS to improve user experience?

In AnQiCMS, optimizing the pagination display of the content list is crucial for improving the user browsing experience.A well-designed, easy-to-use pagination system not only helps visitors efficiently find information but also improves the website's SEO performance.AnQiCMS provides intuitive and powerful template tags, allowing us to easily achieve these goals.

2025-11-09

Does AnQiCMS support setting custom templates for pages of different categories to achieve differentiated display?

In website operation, we often encounter such needs: different types of content or pages with different themes need to be presented in a unique way to better attract visitors, convey information, and even enhance the brand image.This involves the customization ability of the template.AnQiCMS (AnQiCMS) indeed provides strong and flexible support in this aspect, allowing users to set custom templates for pages of different categories to achieve differentiated content display.

2025-11-09

How to use the AnQiCMS recommendation attribute (flag) to filter and display specific content, such as "headline" or "slideshow"?

AnQiCMS provides a flexible recommendation attribute (flag) mechanism that allows website operators to easily filter and highlight specific content, whether it is the "top news" on the website homepage, the "slideshow" in the carousel, or other "recommended" content that needs special attention.This feature greatly enhances the efficiency of content operation and the richness of website content.### Understanding Recommended Attributes: Tag content with "Exclusive Tags" Imagine that you have published many excellent articles and product information, but some are currently the most important, most popular, or need to be displayed in specific locations

2025-11-09

How does AnQiCMS handle and display the lazy loading (lazyload) feature of images in article content?

In website operation, the loading speed of image content is crucial for user experience and search engine optimization (SEO).Especially when an article contains a large number of images, if all the images are loaded all at once when the page loads, it may cause the page to respond slowly and even affect the user's patience.This problem solved, the image lazy loading (Lazyload) technology emerged.

2025-11-09