How to categorize image resources and display them on the front end according to categories?

Calendar 👁️ 76

Images are an indispensable part of website content, they can not only beautify the page but also effectively convey information and improve the user experience.However, with the increase in the number of images on a website, how to efficiently manage these image resources and flexibly display them on the front page as needed has become a challenge for many website operators.AnQiCMS (AnQiCMS) is well-versed in this field, providing a user-friendly and powerful image resource management system that helps us easily handle these visual elements.

Back-end classification management of image resources: Keep everything in order

In Anqi CMS, the classification management of image resources is the foundation for efficient operation.By reasonable classification, we can quickly locate the required image, avoiding the need to search for a needle in a haystack of massive images.

First, you need to log in to the Anqi CMS backend and navigate to"Page Resources"and then click“Image Resource Management”. This is the core hub of all your images and video resources.

Create and organize categories:On the image resource management interface, you will see a "Category Management" area.Click here, you can easily add new image categories.For example, based on the type of website content, you can create categories such as 'Product Display', 'Company Activities', 'Team Style', or 'Article Illustrations'.The AnQi CMS supports multi-level categorization, which means you can create subcategories under the main category, such as 'Mobile Series' and 'Computer Accessories' under 'Product Display', thereby building a clear picture organization structure.

Upload and categorize:When you upload a new image, you can directly select the category it belongs to.For images that have been uploaded but not yet categorized, or images that need to be adjusted for classification, the system provides a convenient batch operation function.You can select multiple images and then transfer them in bulk to the specified category with one click, or delete the images you no longer need.This flexibility greatly improves the efficiency of image management.

Image details and replacement:Click any image, you can enter the detail page to view all the metadata including the filename, file type, upload time, file size, image resolution, and image address.It is worth mentioning that AnQi CMS also provides an image replacement feature.When you need to update an image (such as product image update), you do not need to delete the old image and upload a new one to modify the reference link. Just select Replace on the detail page, the image URL will remain unchanged, but the content will be updated to the new image, which is extremely beneficial for the website's SEO and daily maintenance.It is recommended to clear the local browser cache after replacing or updating images to ensure that the latest images are displayed on the front end.

Image processing options in global content settings:The Anqi CMS provides multiple global configurations for image processing under the 'Content Settings' in the 'Background Settings'.You can choose according to the website requirements whether to 'enable WebP image format' to optimize image size, whether to 'automatically compress large images' and set the compression width, and choose the appropriate 'thumbnail processing method and size' and so on.These settings will be automatically applied to the images you upload, helping the website to improve loading speed while ensuring image quality.

Flexible display of images by category on the front end: Light up your website

After the background image resources are carefully categorized and managed, the next step is how to elegantly present them on the front page.The AnQi CMS template tag system makes this process intuitive and powerful.

The AnQi CMS adopts a template engine syntax similar to Django, using specific tags to call back-end data. In terms of image display, we mainly usearchiveList(Document list),archiveDetail(Document Details),categoryList(Category list) andcategoryDetail(Category Details) and combine image fields such asThumb/Logo/Images) to display images.

Display a collection of category images on a specific page:Suppose you want to create a "company album" page, dedicated to displaying all the pictures under the "company activities" category.You can first create a single page in the background and specify a dedicated template file for it.In this template file, you can usearchiveListLabel to call documents under a specified category (if the image is uploaded as the cover image or content image of the document), or to call the image resource directly.

For example, if you upload an image as a thumbnail (Thumb) for a document and want to display all images in the "Company Activity" category with ID 10, your template code might look like this:

{# 假设我们创建一个名为 "photo_gallery.html" 的模板文件 #}
{% archiveList photoArchives with type="list" categoryId="10" limit="20" %}
    <div class="photo-grid">
    {% for item in photoArchives %}
        <div class="photo-item">
            <a href="{{item.Link}}"> {# 可点击进入图片对应的文档详情页 #}
                <img src="{{item.Thumb}}" alt="{{item.Title}}" loading="lazy" />
                <p>{{item.Title}}</p>
            </a>
        </div>
    {% empty %}
        <p>此分类下暂无图片。</p>
    {% endfor %}
    </div>
{% endarchiveList %}

If your image is uploaded as the "cover image set" (Images) of a document, and you need to display multiple images, you will need toforNested a loop inside a loop:

{# 显示文档的封面组图 #}
{% archiveList documentArchives with type="list" categoryId="10" limit="10" %}
    {% for doc in documentArchives %}
        <div class="document-item">
            <h3><a href="{{doc.Link}}">{{doc.Title}}</a></h3>
            <div class="document-images">
                {% if doc.Images %} {# 检查是否有组图 #}
                    {% for imgUrl in doc.Images %}
                        <img src="{{imgUrl}}" alt="{{doc.Title}}" loading="lazy" />
                    {% endfor %}
                {% else %}
                    <p>暂无图片</p>
                {% endif %}
            </div>
        </div>
    {% endfor %}
{% endarchiveList %}

Display the image of the category on the category page (such as the Banner image):When you want to display the category at the top of a category list page:

Related articles

How to define and use variables for content display in AnQiCMS templates?

AnQiCMS (AnQiCMS) boasts its efficient architecture based on the Go language and flexible template mechanism, making content presentation both powerful and intuitive.In website content operation, we often need to display dynamic information, such as article titles, product prices, contact information, etc., which is inseparable from defining and using variables in templates.Understanding how to flexibly use variables in the AnQiCMS template is the key to building and maintaining an efficient, personalized website.The AnQi CMS template engine has borrowed the syntax from Django, making it very easy to understand the definition and reference of variables. Essentially

2025-11-07

How to reference and display external static resources (such as CSS, JS) in the template?

Referencing and displaying external static resources in AnQiCMS templates, such as CSS style sheets and JavaScript scripts, is a key step in building a functional and visually appealing website.Understand the working principle and recommended practices, which can make our website development work more efficient and flexible.

2025-11-07

How to reflect the high concurrency characteristics of the Go language in the front-end page loading speed?

In today's fast-paced online world, website loading speed has become a core factor in user experience and search engine rankings.Nobody likes to wait for a slow page, and search engines tend to rank websites that respond quickly higher.How can you make your website lightning fast?For users of AnQiCMS, the answer is hidden in its powerful Go language underlying architecture, especially the high concurrency features that Go language boasts.

2025-11-07

How to dynamically display the current year or current time in a template?

In website operation, we often need to dynamically display the current year or time, such as displaying the latest copyright year at the bottom of the website, or marking the generation time of the page accurately in articles.AnqiCMS provides flexible and powerful template functions, making these operations very simple.Next, we will discuss how to implement this requirement in the AnqiCMS template.

2025-11-07

How to configure 301 redirect rules to avoid SEO impact after content adjustment?

Website content operation is a continuous job, with the development of the business, content updates, adjustments, and even optimization of the website structure can lead to changes in page URLs.However, if these URL changes are not handled properly, they often have a significant negative impact on the website's search engine optimization (SEO), such as a drop in rankings, loss of traffic, and so on.This is when the 301 redirect becomes a key tool for us to avoid these negative impacts and maintain the SEO health of the website.### Understanding the value of 301 redirect In simple terms, 301 redirect (Moved

2025-11-07

How to organize reusable display modules in a template through `include`, `extends`, and other tags?

Aq enterprise CMS template: Use `include` and `extends` to create efficient and reusable display modules When using Aq enterprise CMS to build a website, you will quickly find that it is very flexible in organizing content display.Especially when dealing with templates, the built-in Django template engine syntax allows us to build pages efficiently like building with blocks.Today, let's talk about how to cleverly use the powerful tags `include` and `extends` to organize and manage reusable display modules on your website, making your templates cleaner and easier to maintain

2025-11-07

How to display a friendly prompt page to users during website maintenance or upgrade?

During the operation of the website, whether it is system upgrades, data migration, or routine maintenance, it is inevitable that there will be situations where the website needs to be temporarily closed or some functions cannot be accessed.How to convey clear and friendly information to users visiting the website at this time, to avoid confusion or direct loss of users, is the key to improving user experience and maintaining brand image.lucky enough, AnQiCMS provides a simple and efficient mechanism to help us easily deal with such situations. ### Why is it necessary to have a friendly maintenance page for website upgrades?

2025-11-07

How to display independent content and configuration for each site in a Docker-deployed AnQiCMS multi-site environment?

In today's internet operations, many companies or individuals often need to manage multiple websites to serve different brands, products, or target audiences.AnQiCMS (AnQiCMS) leverages its powerful multi-site management capabilities to easily meet this requirement on a single core system.When combined with Docker, a popular containerization technology, how to ensure that each site can run efficiently and independently display its content and configuration has become a topic worth discussing.

2025-11-07