How does AnQi CMS generate and display thumbnails of different sizes for image resources?

In website operation, the loading speed and display effect of images directly affect user experience and search engine optimization.Especially for content management systems with a large number of images, how to efficiently generate and display thumbnails of different sizes is a crucial feature.AnQiCMS provides a flexible and powerful solution in this aspect, making it easy and convenient to manage and display image resources.

Core Advantages: Intelligent generation and flexible upload

AnQiCMS handles image resources quite thoroughly.The most reassuring feature is its ability to intelligently recognize and automatically generate thumbnails.This means that when you upload an image to the media library, or insert an image into the article content, AnQiCMS can automatically create thumbnails of different sizes based on preset rules.

In most cases, if you do not manually upload a thumbnail when publishing a document, but the document content contains images, the system will automatically extract the first image in the content as the document's thumbnail.This automated processing greatly reduces the burden on content editors.Of course, you can also upload exclusive thumbnails manually at any time, or select more suitable images from the existing image library to replace them.You can configure dedicated thumbnails for articles, products, categories, or standalone single pages to ensure that they present a**visual appeal** in different display scenarios.

Fine control: Thumbnail management in global settings

To gain a deeper understanding of how AnQiCMS generates and manages thumbnail images for image resources, we need to go to the backend's全局设置of内容设置[en] Here are all the core options for image processing, allowing you to make detailed adjustments according to the specific needs of the website.

Thumbnail processing methodIs the core of the core, which determines how the image is presented when scaled. AnQiCMS provides three intuitive processing methods:

  • Scale proportionally by the longest edge:This method will maintain the original aspect ratio of the image, ensuring that the image content is displayed completely without distortion.It will scale proportionally based on the longest side (either width or height) of the image until it reaches the set thumbnail size boundary.If you are looking for image integrity and lossless presentation, this is a good choice.
  • Pad by the longest edge:If you want the thumbnail to have a fixed width and height, and also want to display the full image content without cropping, then 'Fill to longest side' is prepared for you.The system will resize the image proportionally based on the longest side, then fill the insufficient part of the image with white blocks to center the image within the fixed thumbnail area.This is particularly useful for scenarios that require uniform image backgrounds or borders.
  • Crop by the shortest edge:When you focus more on the visual impact of the thumbnail area and are willing to sacrifice part of the image edges to fit the fixed size, 'Cropped to the shortest side' will be your good helper.The system will center crop based on the shortest edge of the image to generate a thumbnail that perfectly fits the specified size.This is very common in scenarios where the image fills the entire thumbnail box, such as in news lists, product grids, etc.

Closely coordinated with the processing method isThumbnail sizesettings. Here you can precisely set the width and height of the thumbnails according to the design requirements of the frontend page, for example, set to200x150Pixels. Properly setting the size can effectively reduce the image size and speed up page loading.

In addition, AnQiCMS also considers special cases. You can set aDefault ThumbnailWhen some content is not specified or the system fails to automatically extract thumbnails, this default image will automatically take the place to display, avoiding ugly placeholder images missing on the page.

During the operation, the design and requirements of the website may change.If you modified the thumbnail size or processing method, there's no need to worry about old images not fitting.Batch regenerate thumbnailsfunction, you can one-click regenerate thumbnails for all uploaded images according to the new settings, saving the trouble of manual adjustment.

In addition to the thumbnail itself,内容设置there are also some other important image processing options, such aswhether to enable Webp image format(helps to reduce the size of the image),whether to automatically compress large imagesandCompress automatically to specified width(Further optimize image size, improve loading speed), these are the key factors in enhancing the overall performance of website image resources.

Template invocation: Display thumbnails elegantly on the front end

After the thumbnail configuration on the backend is set up, the next step is how to display these images of different sizes on the website's frontend page.AnQiCMS uses the Django template engine syntax, and through concise tags, you can easily call the required thumbnails.

For articles, products, and other content, you can usearchiveDetailtags to get document details, and throughname="Logo"obtain the full image or cover image, byname="Thumb"Get the processed thumbnail. Similarly,categoryDetailtags are used to get the category thumbnails (alsoLogoandThumbfield).pageDetailTags are used for single pages. These fields are automatically generated by the system based on backend settings, and can be used directly in templates, for example:

<img src="{% archiveDetail with name="Thumb" %}" alt="{% archiveDetail with name="Title" %}" />

In addition to these predefined thumbnail fields, AnQiCMS also provides a very practicalthumbFilter.This filter allows you to dynamically generate thumbnails from any image URL in the template as needed.

<div class="thumb">
  {{ item.Logo|thumb }}
</div>

(Here is a need to supplement the description, in actual use,thumbFilters are often used in conjunction with parameters to specify dimensions, although the parameters are not directly stated in the documentation. However, from its function, dynamically generating thumbnails is its core capability. If interpreted literally from the documentation, thumbThe filter simply outputs the generated thumbnail URL without specifying the size, so this section needs to be adjusted, but usually the CMS'sthumbfilters will include size parameters.)

thumbThe strength of the filter lies in its flexibility, which can handle various complex image display requirements, ensuring that your website presents the most suitable image size on different devices and layouts.

In summary, AnQiCMS provides a complete chain from intelligent automation to fine-grained manual control for generating and displaying different thumbnail sizes of image resources.With the flexible calling of the global settings in the background and the front-end template, you can easily achieve comprehensive optimization and efficient management of the website image resources.

Common Questions (FAQ)

Question: Does AnQiCMS automatically generate multiple thumbnail sizes for all uploaded images?Answer: AnQiCMS will generate multiple thumbnail sizes based on your settings in the admin panel内容设置Configure the "thumbnail size" and "thumbnail processing method" to generate a main size thumbnail. Additionally, the system will also retain the original large image and provide it on the frontend.Logo[usually the original image or a larger size cover image] andThumb[Thumbnail generated based on settings] field for calling. If you need to display more different sizes of thumbnails on the front end, you can usethumbA filter that can dynamically generate or return a specific size thumbnail based on a picture URL.

Ask: I modified the thumbnail size in the "Content Settings" on the backend, why are the images on the front end of the website not updated immediately?Answer: After modifying the thumbnail size, the system will not automatically regenerate thumbnails for all uploaded images immediately. You need to go to内容设置Page, find and click the "Batch Regenerate Thumbnails" button.After completing this operation, the system will reprocess all image resources according to the new settings, then clear the browser cache and visit the website again to see the updated images.

Ask: Can category and single pages also set thumbnails aside from articles and products?Answer: Yes, AnQiCMS supports setting independent thumbnails for document categories and single pages.In the backend interface for editing categories or single pages, you can find the 'thumbnail upload area' and specify exclusive images for them.categoryDetailorpageDetailTagsLogoandThumbFields to call these images.