Is the `thumb` filter usable to process the image URL obtained from `categoryDetail` or `pageDetail`?

When using AnQiCMS templates, we often encounter the need to handle image links, especially for thumbnail display. The system provides various methods to obtain images, one common issue being aboutthumbFilter is related tocategoryDetailorpageDetailThe combination of picture fields in the tag.

Firstly, let's understand the basic logic of AnQiCMS in image processing.Auto CMS is dedicated to providing efficient content management, which also includes optimization of image resources.In the background content settings, we can configure the thumbnail processing method, size, and even set a default thumbnail.This means that the system has already intelligently processed the thumbnail version of the image when uploading images or generating content.

When we go throughcategoryDetailTag to get category information, or throughpageDetailWhen the tag gets the details of a single page, these tags' data structure usually contains a field namedThumbThe field. It is not difficult to see from the document that whether it is category details or single page details, itsThumbThe field directly returns the thumbnail address after system processing. For example, when you need to display a category thumbnail, you can call it directly like this:

<div>分类缩略图:<img style="width: 200px" src="{% categoryDetail with name="Thumb" %}" alt="{% categoryDetail with name="Title" %}" /></div>

or get the thumbnail of a single page:

<div>单页缩略图大图:<img src="{% pageDetail with name="Thumb" %}" alt="{% pageDetail with name="Title" %}" /></div>

As you can see,ThumbThe field has provided a ready-made thumbnail URL for us, and we do not need to perform any additional thumbnail processing.This is because AnQiCMS has already pre-generated and stored these thumbnails according to the settings on the back-end.

Then, when should we use it?thumbWhat about filters?

thumbfilters (for example{{ image|thumb }}The original intention of the design of)The original, full-size image URLConvert it dynamically to a thumbnail.It is not used to process images that have already been thumbnail processed.bannerListwas obtained at that timeitem.Logo(usually the original image), and you want to display it as a thumbnail at some place,thumbThe filter comes into play. It will dynamically generate or return a thumbnail of the corresponding size based on this original image URL.

For example, when iterating through the Banner list, if you want to resize the Logo image of the Banner:

{% bannerList banners %}
    {% for item in banners %}
    <a href="{{item.Link}}" target="_blank">
        <img src="{{item.Logo}}" alt="{{item.Alt}}" />
        <div class="thumb">
          {{ item.Logo|thumb }}
        </div>
    </a>
    {% endfor %}
{% endbannerList %}

Here,item.Logois the original image address, through|thumbFilter, we got its thumbnail version.

In summary, when you are usingcategoryDetailorpageDetailtags to get images, if the one you get isThumbField, then it is already a thumbnail URL, you can use it directly. You do not need to apply it again.thumbFilter.thumbThe filter is mainly used to process those cases where you explicitly know the original large image URL and want AnQiCMS to dynamically generate its thumbnail.Understanding these two methods of obtaining and processing image URLs can help us display images more efficiently and accurately in the AnQiCMS template, and also make better use of the system's built-in image optimization capabilities.


Common Questions (FAQ)

1. I can pass it directly tocategoryDetailorpageDetailThe one obtainedLogofield (usually a large image) tothumbDoes the filter perform thumbnail processing?Yes, it can be done completely.LogoThe field usually returns the category or single-page original large image address (or larger image). If you wish to display it in a template differentlyThumbThe default thumbnail size provided by the field is used to displayLogoto{{ categoryDetail with name="Logo" }}or{{ pageDetail with name="Logo" }}results, and then through|thumbFilter processing. For example:<img src="{{ categoryDetail with name='Logo' }|thumb}" />.

2.thumbIs the thumbnail size generated by the filter fixed? Can I customize it? thumbThe thumbnail size generated by the filter is determined by the "Thumbnail Size" configured in the "Content Settings" of the AnQiCMS backend.If you need different thumbnail sizes, you can adjust these global settings in the background.But it should be noted that these settings are applied to the entire site. If you want to implement more fine-grained on-demand customization of sizes, you may need to consider multi-size processing when uploading images, or use custom fields to store links to images of different sizes.

3. If IThumbField reusagethumbthe filter, what will happen?In most cases, applying a thumbnail URL againthumbis an unnecessary operation. According to the logic of AnQiCMS,ThumbThe field is the thumbnail URL itself; further filtering may not produce additional image size changes, or it may return the same result. **Practicality is to avoid this redundant operation and use it directly.Thumbfield.