How to configure and display thumbnails with different processing methods (such as cropping, scaling)?

Calendar 👁️ 69

Drive AnQi CMS thumbnail: fine-tuning configuration and flexible display, creating visual impact

In website operation, images are undoubtedly the key elements that attract users and enhance the quality of content.While thumbnails, as the first visual point of website content, their display effect directly affects users' desire to click and the overall beauty of the page.AnQi CMS knows this and provides us with flexible thumbnail configuration and display capabilities, helping us easily manage and present high-quality image content.

Core configuration: thumbnail management in the background content settings

The thumbnail configuration of AnQi CMS is mainly located in the "Content Settings" module of the backend.To get here, we just need to enter the background management interface, find the "Background Settings" in the left menu, and then click "Content Settings."}Here, we will see a series of options related to image processing, which together constitute the generation logic of the website thumbnail.

Among the most critical are the 'thumbnail processing method' and 'thumbnail size' options.

Understand the different thumbnail processing methods.

The AnQi CMS provides three different thumbnail processing methods to meet various design and display needs:

  1. Scale proportionally to the longest sideThis method aims to preserve the original content of the image, avoiding any cropping.The system will find the longest side of the image (either width or height) based on the thumbnail size we set and scale it proportionally from that basis.The thumbnail generated will have its longest side equal to the size we set, and the other side will be adjusted proportionally.

    • Applicable scenariosWhen the integrity of the image is crucial and no part should be cropped, for example, product close-ups, art work display, etc.This method ensures that the image content is not missing, but in some layouts, different proportions of images may lead to visual misalignment or blank spaces.
  2. Fill the longest side: If we have strict size requirements for thumbnails, hoping that all thumbnails will present a uniform aspect ratio, and at the same time not want to crop the image content, then 'filling with whitespace on the longest side' is the ideal choice.The system will first resize the image proportionally along the longest side to fit the specified size, then fill the insufficient part of the image (usually the shorter side) with white or other specified color until the preset thumbnail size is reached.

    • Applicable scenariosVery suitable for grid layouts, card display, and other scenarios that require strict uniform dimensions.For example, news lists, product albums, etc., can ensure that all thumbnails are visually uniform, enhancing the professionalism of the website.
  3. Trim according to the shortest edge:“Trimming to the shortest edge” is a more direct approach, which ensures that the thumbnail will ultimately present the size and ratio we set.The system will first center the image, then crop it based on the shorter edge of the image to remove the excess part.

    • Applicable scenariosWhen we need a unified image size and the main information of the image is concentrated in the central area, this method is very effective.For example, portraits, cover images, and others can quickly generate thumbnails that meet design requirements, highlighting the visual focus.It should be noted that if the key information of the picture is located at the edge, it may be lost in the cropping.

Set thumbnail size

After selecting the appropriate method, the setting of "thumbnail size" is also crucial.Here you usually need to enter a width value and a height value, for example, '200x150'.This size will guide the system on how to generate the final thumbnail.Setting the size reasonably can effectively reduce the file size of images, speed up page loading, and improve user experience.Suggest determining a size based on the actual design requirements of the website and the image display area.

Other related configuration items

In addition to the above core settings, there are some options related to image processing that are worth paying attention to:

  • Default thumbnailWe can upload an image as the default thumbnail. When the document or content does not upload its own thumbnail, the system will automatically use this default image to replace it, to avoid the embarrassment of blank pages or missing images.
  • batch regenerate thumbnailsWhen the thumbnail configuration of the website changes (for example, the processing method or size is modified), you can use this feature to batch regenerate the thumbnails of all uploaded content with one click to ensure the consistency of the display of images throughout the site.
  • Whether to automatically compress large images: Enable this feature and set 'Auto-compress to specified width', which can automatically compress images when the user uploads images that are too large, helping to control the image storage space and loading speed of the website.
  • Whether to enable Webp image formatConvert images to WebP format automatically, which can significantly reduce image size while maintaining high image quality, further optimizing website performance.

Flexibly use: Thumbnail display in the template

After configuring the thumbnail generation rules on the backend, the next step is to call and display these thumbnails in the front-end template.The Anqi CMS template language is concise and efficient, calling thumbnails is very convenient.

Generally speaking, when we go througharchiveList(Document list),categoryList(Category list),pageList(Single-page list) and other tags to obtain content data, eachitem(Whether it is a document, category, or single page) it will contain oneThumbfield that directly points to the thumbnail URL generated after the system processes the background settings.

For example, when displaying a document list:

{% archiveList archives with type="list" limit="10" %}
    {% for item in archives %}
        <li>
            <a href="{{item.Link}}">
                <h5>{{item.Title}}</h5>
                {% if item.Thumb %}
                    <img alt="{{item.Title}}" src="{{item.Thumb}}">
                {% endif %}
            </a>
        </li>
    {% endfor %}
{% endarchiveList %}

And on the document detail page, we can also directly access through:archiveDetailthe tag to get the thumbnail of the current document:

<div>
    {% archiveDetail with name="Thumb" %}
</div>

Or use a variable to receive and display it:

{% archiveDetail archiveThumb with name="Thumb" %}
<img src="{{archiveThumb}}" alt="文档缩略图"/>

For category or single-page thumbnail calls, the logic is similar:

{# 分类缩略图 #}
{% categoryDetail categoryThumb with name="Thumb" %}
<img src="{{categoryThumb}}" alt="分类缩略图" />

{# 单页缩略图 #}
{% pageDetail pageThumb with name="Thumb" %}
<img src="{{pageThumb}}" alt="单页缩略图" />

Moreover, Anqi CMS also providesthumbA filter that can be applied to any image URL in the template to use the system-defined thumbnail processing rules. This means that even if you have a nonThumbThe field's image URL, which can also be processed uniformly with this filter. For example:

{% bannerList banners %}
    {% for item in banners %}
        <a href="{{item.Link}}" target="_blank">
            <img src="{{item.Logo|thumb}}" alt="{{item.Alt}}" /> {# 对Banner图片的URL应用缩略图处理 #}
            <h5>{{item.Title}}</h5>
        </a>
    {% endfor %}
{% endbannerList %}

By these flexible calling methods, we can ensure that all images on the website, whether content thumbnails or other image resources, are presented to users in a unified and optimized manner.

Use Tips and Optimization Suggestions

  • Responsive Design: In addition to backend settings, use front-end CSS with images,max-width: 100%; height: auto;and other properties to ensure that thumbnails display well on different devices.
  • Balancing quality and performance: Although AnQi CMS provides automatic compression and WebP conversion features, it is still recommended to use high-quality but appropriately sized images when uploading original images, as this is the basis for optimizing website loading speed.
  • SEO optimizationIn<img>Tagged,altThe attribute is indispensable. It not only helps search engines understand the content of the image, but also provides text descriptions when the image cannot be loaded, enhancing user experience and website accessibility.

By the above configuration and call, we can easily manage and display thumbnails of different processing methods in Anqi CMS, making the website's image content more professional, beautiful, and efficient.


Common questions (

Related articles

How to automatically compress images based on size and display them on the front-end?

In website operation, images are an important element to attract visitors and convey information.However, large, unoptimized images often become the 'killer' of website loading speed, not only affecting user experience, but also possibly dragging down search engine rankings.Luckyly, AnQiCMS (AnQiCMS) provides very intelligent and practical image processing functions that can help us easily cope with these challenges, making images clear and fast when displayed on the front end.### Smart compression, goodbye to manual adjustment of large images Have you ever encountered such a situation: in order to maintain image quality

2025-11-08

How to batch generate and display images in Webp format in AnQi CMS?

Website performance is one of the key factors that determine user experience and search engine rankings.Among various optimization methods, image optimization plays a vital role.WebP is a modern image format that boasts excellent compression performance and almost lossless visual quality, and is gradually becoming the new standard for website optimization.How can we efficiently generate and display WebP images in the Anqi CMS management website?AnQi CMS provides very convenient and powerful functional support in this aspect, allowing you to easily achieve the WebPization of website images without delving into technical details

2025-11-08

How to truncate long text content and display an ellipsis?

In the operation of daily websites, we often encounter such situations: the content of the article detail page is rich, but the list page or recommendation module needs to display a concise version of the content for the sake of page layout, usually by truncating a part of the text and adding an ellipsis at the end.AnQi CMS understands the importance of content display and provides very convenient and powerful tools to handle such needs.Let's take a look at how to elegantly implement the truncation of long text content and display an ellipsis in Anqi CMS, making the website interface both beautiful and professional.The need and value of content truncation in many display scenarios

2025-11-08

How to avoid XSS attacks and safely display HTML content when outputting?

In website content management, ensuring the safe display of information, especially in preventing cross-site scripting (XSS) attacks, is an important issue that every content creator and website administrator must face.XSS attacks exploit vulnerabilities in websites, injecting malicious code into web pages. When other users visit the web page, the malicious code will execute on the user's browser, potentially stealing user information, hijacking sessions, or even tampering with web content, posing serious harm to the website and users.Fortunately, AnQiCMS has fully considered content security from the beginning of its design, providing us with multiple protective measures

2025-11-08

How to display detailed information of the currently logged-in user (such as username, avatar, VIP status)?

In Anqi CMS, displaying the detailed information of the currently logged-in user, such as username, avatar, and VIP status, is a key step to enhance user experience and build a personalized website.AnQi CMS with its flexible template engine allows us to easily implement these features.This article will introduce how to display this information on your website front-end. ## Retrieve basic information of the currently logged-in user The Anqi CMS template system provides the `userDetail` tag, which is the core tool for retrieving various information of the currently logged-in user.This tag can directly retrieve the user data of the current session

2025-11-08

How to display the names and introduction information of different user groups?

Displaying different user group names and introduction information in AnQi CMS is an important part of website personalized operation and content distribution.Whether you want to display exclusive identification for VIP members or provide customized content for users with different permissions, Anqi CMS's flexible template tag system can help you easily achieve this. ### Understanding the Core Concepts of User Group Information To display the name and introduction of the user group, it is first necessary to clarify two key points: whether the user is logged in, and which user group the user belongs to. Safe CMS provides powerful template tags

2025-11-08

How to conditionally display different content or styles within a loop?

In website content display, we often encounter the need to display different content or assign unique styles to elements according to the order of data cycles, specific attributes, or states.For example, odd and even rows in the list need different background colors, special markings for certain types of products, or when a field is empty, hide the corresponding area.With its flexible and powerful Django-like template engine, AnQi CMS makes these requirements simple and easy to implement.By cleverly combining loop tags (`{% for ... %}`) and conditional judgment tags (`{% if ... %}`)

2025-11-08

How to define and display temporary variables in the template?

In Anqi CMS template development, mastering how to define and display temporary variables in the template is a very practical skill.It can help us handle data more flexibly, optimize template structures, and write more concise and efficient code.Temporary variables are like the "small tags" you grab on the fly while making a page, used to temporarily store some data for later use.### Why do we need temporary variables? Imagine a scenario: you might need to get a value from a label and then perform a series of operations on it (such as truncating strings, formatting time)

2025-11-08