How to get the thumbnail version of the image in AnQiCMS template?

Calendar 👁️ 60

As an experienced security CMS website operator, I fully understand the importance of high-quality content and excellent user experience.In the visual presentation of a website, images play a core role, and the optimization of images, especially the application of thumbnails, is of great value in improving page loading speed, enhancing user experience, and improving search engine rankings.Anqi CMS provides strong and flexible support in this aspect, allowing operators to easily obtain and display thumbnail versions of images in templates.

In today's content-driven internet environment, it is common for web pages to contain a large number of images.However, directly loading the original large image often leads to slow page loading, seriously affecting user experience.At this moment, providing an appropriately sized thumbnail for the image becomes the key to solving this problem.AnQi CMS fully understands this, its built-in image processing mechanism can automatically generate and manage thumbnail versions of images, greatly simplifying the work of website operators, allowing us to focus more on content creation and optimization.

The thumbnail mechanism of AnQi CMS is highly intelligent. After the image is uploaded to the content management system, the system will automatically process the image according to the background configuration to generate thumbnails of different sizes.This means that even if the content editor uploads a high-resolution large image while writing the article, the front-end page can automatically display the optimized thumbnail according to the template's call requirements.This automated processing not only ensures the high efficiency of image loading, but also avoids layout chaos caused by overly large images, ensuring the uniformity of the overall visual style of the website.

In Anqi CMS template, get the thumbnail version of the image, mainly relying on its powerful template tag system.For document (archive), category (category), and single page (page) content, Anqi CMS provides specific tags to retrieve the corresponding image resources, including thumbnails, featured images, and group images.These tags are usually passed through loops or detail pagesitemorarchive/category/pageReference by variable and pass through.Thumbor.LogoDirectly access the thumbnail path via properties.

In particular, when we need to display the document thumbnail in the article list or detail page, we can usearchiveListorarchiveDetailtags. For example, to get the document cover thumbnail, we can directly call{{item.Thumb}}or{{archive.Thumb}}. Here,ThumbThe attribute points to the thumbnail version automatically generated by the system. At the same time,LogoProperties are usually used to get the cover image of the document, which may be a larger thumbnail or an image processed in a specific way, depending on the backend configuration. If the document contains multiple group images,ImagesThe property will return an array of image URLs, and operators can iterate over this array in the template to display a multi-image carousel or gallery.

{# 在文档列表(archiveList)中获取缩略图示例 #}
<div>
{% archiveList archives with type="list" categoryId="1" limit="10" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            {# 使用 item.Thumb 获取缩略图 #}
            {% if item.Thumb %}
                <img alt="{{item.Title}}" src="{{item.Thumb}}">
            {% endif %}
            <div>{{item.Description}}</div>
        </a>
    </li>
    {% endfor %}
{% endarchiveList %}
</div>

{# 在文档详情页(archiveDetail)中获取缩略图示例 #}
<article>
    <h1>{% archiveDetail with name="Title" %}</h1>
    <div>
        {# 使用 archive.Thumb 或 archive.Logo 获取缩略图/首图 #}
        <img src="{% archiveDetail with name="Thumb" %}" alt="{% archiveDetail with name="Title" %}" />
        <img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />
    </div>
    <div>
        {%- archiveDetail articleContent with name="Content" %}
        {{articleContent|safe}}
    </div>
</article>

Similarly, for the category page, whether it is to get the category list (categoryList) or the category details (categoryDetail),we can also useitem.ThumborcategoryDetail with name="Thumb"To get the category thumbnail.Logoattributes andImagesProperties are also applied in a similar way to categorized content, providing cover images and group images. Single-page and tag pages also follow a similar calling logic, through the correspondingpageDetail/pageListortagDetailtags and their.Thumbor.LogoProperty to get the image.

{# 在分类详情页(categoryDetail)中获取缩略图示例 #}
<div>
    <h1>{% categoryDetail with name="Title" %}</h1>
    {# 获取分类缩略图 #}
    <div>
        <img style="width: 200px" src="{% categoryDetail with name="Thumb" %}" alt="{% categoryDetail with name="Title" %}" />
    </div>
    {# 获取分类 Banner 组图,并只显示第一张 #}
    {% categoryDetail bannerImages with name="Images" %}
    {% if bannerImages %}
        {% set pageBanner = bannerImages[0] %}
        <div class="page-banner" style="background: url({{pageBanner}}) no-repeat;"></div>
    {% endif %}
</div>

The image processing strategy of Anqi CMS can be finely configured in the "Content Settings" backstage.The operations personnel can flexibly adjust the thumbnail processing method according to the actual needs of the website (such as proportional scaling by the longest side, filling by the longest side, or cropping by the shortest side), set a unified size for thumbnails, and even upload a default thumbnail to ensure that there is an image display when no thumbnail is specified for the content.These settings enable the website to pursue visual effects while also considering performance and consistency.

In summary, AnQi CMS provides a comprehensive and convenient solution for acquiring and managing image thumbnails.Through intuitive template tags and flexible backend configuration, website operators can easily achieve optimized image display without delving into complex code, thereby providing users with a smoother and more beautiful browsing experience, and laying a solid foundation for the long-term development of the website.


Frequently Asked Questions (FAQ)

What is the difference between the thumbnail and the original image provided by AnQiCMS?AnQiCMS provides a thumbnail that is the image version generated by the system through automatic processing of the original image (such as compression, cropping, scaling).Compared to the original image, the thumbnail's size and file size are usually significantly reduced to accommodate web page loading speed and layout requirements.The original image retains the original resolution and quality and is often used for high-definition viewing or downloading after the user clicks on the thumbnail.

What will AnQiCMS do if no thumbnail is uploaded for the document, category, or page?If the thumbnail is not manually uploaded, AnQiCMS will automatically process according to the 'Content Settings' configuration in the background.In general, the system will try to automatically extract the first image in the content as a thumbnail.If the content does not contain any images and the backend is set to 'default thumbnail', then this default thumbnail will be displayed.This mechanism ensures that the page can maintain visual integrity even in the absence of a specific thumbnail.

How can I change the size or processing method of the thumbnails generated by AnQiCMS?To change the thumbnail size or processing method generated by AnQiCMS, you need to log in to the backend management system and navigate to the "Content Settings" page under "Backend Settings".On this page, you can find options such as 'thumbnail processing method' (supporting proportional scaling by the longest side, padding by the longest side, and cropping by the shortest side), 'thumbnail size', and 'batch regenerate thumbnails'.Adjust according to your needs and save the settings, then you can consider using the 'Batch regenerate thumbnails' feature to update the thumbnail versions of all uploaded images.

Related articles

How to judge if a variable is empty in AnQiCMS template and set a default value?

As a senior AnQi CMS website operation personnel, I know that handling variables with flexibility and robustness is crucial in template development and content display.Especially when the data source may be uncertain or missing, how to elegantly judge whether a variable is empty and provide a reasonable default value, which directly affects the user experience and the stability of page rendering.The AnQi CMS, with its template engine similar to Django, provides us with powerful and intuitive tools to meet these challenges.

2025-11-06

How to ensure safe output of HTML content without escaping in AnQiCMS templates?

As an experienced website operator proficient in AnQiCMS, I am well aware of the importance of secure content output, while also ensuring the complete presentation of high-quality content.In AnQiCMS template development, dealing with HTML content often encounters a core issue: how to ensure that these HTML contents are rendered as expected and not escaped to plain text by the template engine?This not only involves the display effect of the content, but also concerns the security of the website.AnQiCMS uses a syntax similar to the Django template engine, one of its core design philosophies is security.This means

2025-11-06

How to cut, replace, or format strings in AnQiCMS templates?

As an experienced CMS website operation personnel in a safety company, I fully understand the importance of content in attracting and retaining users.A powerful and flexible template system that allows us to accurately present content according to different scenarios and user needs.AnQiCMS with its Django template engine syntax, provides us with rich string processing capabilities, whether it is for slicing, replacing, or formatting, it can be easily realized, thus transforming the original data into captivating web content.### AnQiCMS in template string variable acquisition and basic processing in

2025-11-06

How to define and use macro functions to create reusable code blocks in AnQiCMS templates?

As an experienced security CMS website operation personnel, I am well aware that the template function of the content management system is crucial for improving website operation efficiency and content display quality.AnQiCMS's powerful Django template engine syntax provides us with flexible content presentation capabilities, and the Macro function feature is an essential tool for code reuse, simplifying template structure, and improving development and maintenance efficiency.During the process of content creation and publishing, we often encounter some repetitive code snippets, such as the display format of article lists and the layout of product cards

2025-11-06

How to call the switch link of multi-language sites in AnQiCMS template?

As a senior CMS website operator for an enterprise security company, I know that the multilingual site switching link is crucial for expanding the international market and improving user experience.AnQi CMS provides us with a convenient and efficient solution with its powerful multi-site and multi-language support function.Below, I will elaborate on how to call the multilingual site switch link in the AnQiCMS template.Flexible construction of multi-language site switching function Anqi CMS has fully considered the needs of enterprises and operators in global layout from the beginning of its design, originally supporting multi-site management and multi-language content switching

2025-11-06

How to dynamically display the home page banner list in AnQiCMS template?

As a senior who has been deeply engaged in AnQiCMS content operation for a long time, I know the importance of the homepage banner for the visual appeal and marketing promotion of the website.A well-designed and dynamic Banner list that can quickly attract visitors' attention and effectively convey the latest product, service, or event information.Today, I will demonstrate in detail how to dynamically display the Banner list on the website homepage based on the powerful template function of AnQiCMS.

2025-11-06

How to remove the blank lines that may be generated by logic tags in the AnQiCMS template?

As an experienced CMS website operation personnel of an enterprise, I know that every detail of content presentation is crucial, including seemingly trivial blank lines.In a meticulously constructed template, unnecessary blank lines not only affect the neatness of the HTML code, but may also cause unexpected visual problems in certain layouts.Today, let's delve into how to efficiently remove blank lines that may be generated by logical tags in the AnQiCMS template.

2025-11-06

How to create a multi-level website navigation menu in AnQiCMS template?

As an experienced AnQiCMS website operations staff, I know that a clear and efficient multi-level website navigation menu is crucial for user experience and website SEO.AnQiCMS provides a comprehensive mechanism in template design and backend management, helping us easily build such a menu.I will elaborate in detail on how to create a multi-level website navigation menu in the AnQiCMS template.

2025-11-06