How to call and display the cover image, thumbnail, or group image of a specified document?

Calendar 👁️ 82

It is crucial to have visually appealing content when building and operating a website.AnQiCMS provides a flexible way to manage and display the images of documents (including articles, products, etc.), whether as an eye-catching cover, a delicate thumbnail, or a colorful collage.Understand how to correctly call these images, which can help you better design and optimize the user experience of the website.

AnQiCMS provides several main image fields for different content types, which have clear uses in templates:

  • Cover LogoThis usually refers to the main visual or representative image of the content (such as documents, categories, single pages). In some contexts, it may be the first image to highlight.
  • Thumbnail (Thumb)This is a smaller, processed version of the cover main image, often used on list pages and recommendation areas to save loading time and keep the page neat.
  • Images (Images)When it is necessary to display a set of images to describe a content in detail (such as product multi-angle display, event photo album), AnQiCMS will store these images as an array.

We will discuss how to call and display these images in the AnQiCMS template.


Call images in the document details page.

On the document detail page, you usually want to display the most complete and highest quality images. AnQiCMS providesarchiveDetailLabel to get the detailed information of the current document, including the associated images.

To display the cover thumbnail of the document, you can call it like this.LogoField:

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

here,altProperties are a good habit, they not only help search engines understand the content of the image, but also provide text descriptions when the image cannot be loaded. You can also directly use variables from the current document context, such as:

<img src="{{archive.Logo}}" alt="{{archive.Title}}" />

If your document is configured with a thumbnail and you want to display it at a certain location on the detail page (such as the sidebar), you can callThumbField:

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

Similarly, if you are directly inarchiveUsing in context, the code will be more concise:

<img src="{{archive.Thumb}}" alt="{{archive.Title}}" />

When the document contains multiple images as a collage, you need to use aforto loop throughImagesfield. BecauseImagesthe field returns an array of image links:

{% archiveDetail archiveImages with name="Images" %}
<div class="image-gallery">
    {% for imgUrl in archiveImages %}
        <img src="{{imgUrl}}" alt="{{archive.Title}} - 图片 {{ forloop.Counter }}" />
    {% endfor %}
</div>

In this example,forloop.CounterIt provides the current image sequence number in each loop, which is very suitable for use inaltproperties to enhance the uniqueness of image descriptions.


calling images on the document list page

On the document list page (such as article list, product list), it is usually only necessary to display thumbnails to get an overview of the content, rather than the full cover image.archiveListThe tag is used to retrieve a series of documents, you canforaccess each document's image field in a loop.

When you usearchiveListWhen looping through documents, each document item will be assigned a variable (for exampleitem)。To display the thumbnail of each list item, you can do this:

{% archiveList archives with type="page" limit="10" %}
    {% for item in archives %}
        <div class="list-item">
            <a href="{{item.Link}}">
                <h3>{{item.Title}}</h3>
                {% if item.Thumb %}
                    <img src="{{item.Thumb}}" alt="{{item.Title}} 的缩略图" />
                {% endif %}
                <p>{{item.Description}}</p>
            </a>
        </div>
    {% endfor %}
{% endarchiveList %}

We used here{% if item.Thumb %}To determine if the thumbnail exists. This is a very practical skill that can avoid displaying corrupted image icons when there are no images, thereby improving user experience.

If the list item needs to display the cover thumbnail (although it is not common), it can also be called{{item.Logo}}. And if you need to display multiple images in the list item, you can nestitemone insideforto loop through{{item.Images}}An array, like displaying a group of images on the detail page.


Call images in categories and single pages.

AnQiCMS not only provides an image field for documents, but also allows you to configure cover images, thumbnails, and group images for categories and single pages. They are called in a similar way to documents, just by using the corresponding tags:

  • Category Image: Use.categoryDetailTag to get the current category image (for example{{category.Logo}}/{{category.Thumb}}/{{category.Images}}), or incategoryListthrough the loop{{item.Logo}}and so on.)
  • Single Page Image: Use.pageDetailTag to get the current single page image (for example{{page.Logo}}/{{page.Thumb}}/{{page.Images}}), or inpageListthrough the loop{{item.Logo}}and so on.)

No matter what type of content, AnQiCMS provides a clear image upload and management interface in the background, ensuring that you can easily add visual elements to your content.


Common Techniques to Enhance Image Display Effect

In addition to the basicsrcproperties, there are some common techniques that can help you optimize image display:

  • Automatic image path processing: AnQiCMS will automatically handle the storage path of the uploaded image, you can directly call it in the template{{item.Logo}}or{{archive.Thumb}}Leave the fields as is, there is no need to manually concatenate complex server paths, the system will return the complete image access URL.
  • addaltproperty: Always set to<img>tagsaltAttribute, this not only benefits SEO (Search Engine Optimization), but also provides text descriptions when images cannot be loaded, enhancing the accessibility of the website.
  • Conditional judgment: Before displaying the image, use{% if 变量名 %}Check to ensure that the image field has a value. This can effectively avoid displaying a placeholder for 'Image Missing' and maintain the beauty of the page.
  • Responsive image processingAlthough template tags directly output image links, you can combine them with CSS frameworks (such as Bootstrap, Tailwind CSS) or the nativesrcsetProperties,<picture>To implement responsive images, so that images can display well on different devices.

By flexibly using these tags and fields provided by AnQiCMS, you can easily add rich visual elements to your website content, whether it's an eye-catching cover, a concise thumbnail, or a detailed album display, all of which can be perfectly presented to enhance the professionalism and user experience of your website.


Frequently Asked Questions (FAQ)

1. Why have I uploaded pictures for the document but they are not displayed on the front page?

This could be caused by several reasons. First, please check if the image field name you are using in the template is correct, for example isLogo/ThumbOrImagesNext, confirm that the image has been successfully uploaded and saved to the document, you can view it while editing the document in the background.Again, AnQiCMS has a caching mechanism, if the front-end does not take effect immediately after the back-end is modified, try clicking the "Update Cache" button on the back-end, or clear your browser cache and try again.Finally, make sure you have used in the template{% if 图片字段 %}Such conditional judgment, to prevent the image field from being empty and skipping the image display.

2.LogoandThumbWhat are the differences between these image fields? When should I use them?

LogoGenerally refers to the 'cover lead image' or main image of a document, usually larger in size, used to highlight the visual theme of the document in detail pages or important display areas.ThumbIt is a "thumbnail", which isLogoa smaller size version, intended for use on list pages, recommendation modules, or sidebars, etc., to save page space

Related articles

How to display the document title, publish time, and view count on the document detail page?

Manage website content in AnQi CMS and ensure its accurate and beautiful display on the front-end page, which is the core of daily operation work.For each document detail page, clearly presenting the title, publication time, and views of the document can not only effectively improve user experience, but is also an important link in the transmission of content information.The AnQi CMS provides powerful and flexible template tags, allowing us to easily meet these requirements. ### Locate the document detail page template To modify the display content of the document detail page, we first need to find the corresponding template file.In AnQi CMS template structure

2025-11-08

How to display mathematical formulas and flowcharts on AnQiCMS web pages?

Today, with the increasingly rich digital content, it often seems inadequate to convey complex information solely through text.Especially in fields such as science, technology, and education, mathematical formulas and flowcharts are the key to expressing rigorous logic and clear steps. 幸运的是,AnQiCMS provides a simple and powerful way to easily integrate and display these professional contents on your web page. This article will introduce in detail how to use the Markdown editor and third-party libraries on your AnQiCMS website to achieve perfect presentation of mathematical formulas and flowcharts.

2025-11-08

How to correctly render Markdown editor content on the frontend page in HTML?

## AQS CMS Markdown content: How to perfectly present on the front-end page?In content creation, Markdown, with its concise and efficient syntax, has been favored by a wide range of content creators.AnQi CMS knows this and therefore provides strong Markdown editor support.But how can you ensure that the Markdown content you edit in the background is rendered correctly and beautifully on the website's frontend page?Behind this involve several key links, understanding them can help you manage the website content more skillfully.

2025-11-08

How can you reference common header, footer, or sidebar content in a template?

In the daily operation and maintenance of the website, we often encounter such situations: each page needs to include a unified header, a standard footer, or a fixed sidebar.If every page were to rewrite this content, it would not only be inefficient but also a huge amount of work to modify once.AnQiCMS (AnQiCMS) understands this pain point and therefore provides a flexible and powerful template reference mechanism to help us efficiently manage these common contents, ensuring the unity and maintainability of the website.### Overview of AnQi CMS Template Mechanism In AnQi CMS

2025-11-08

How to implement lazy loading of images in document content to optimize display performance?

## Optimize Website Display Performance: Practical Guide to Implementing Lazy Loading of Images in AnQi CMS In today's internet era, the loading speed of a website is crucial for user experience and search engine rankings.Large image files are often one of the main culprits slowing down website loading speeds. 幸运的是,image lazy loading (Lazy Loading) technology can effectively solve this problem.

2025-11-08

How to get and display the name and link of the category to which the current document belongs?

On the content detail page of a website, we often hope to clearly display the classification information of the current document, such as the name of the classification and the link to that classification.This not only helps visitors better understand the content structure, but also improves the website's navigation and user experience.Safe CMS provides us with a variety of flexible ways to meet this requirement. We will discuss several methods for obtaining and displaying the category name and link of the current document in the AnQiCMS template, and you can choose the most suitable solution according to your actual template design and requirements.### Method One

2025-11-08

How to display a list of recommended documents related to the current document on the document detail page?

In website content operations, providing users with relevant recommended content not only effectively enhances the depth and duration of page browsing, but also optimizes user experience, indirectly assisting in the SEO performance.In AnQiCMS (AnQi Content Management System), implementing this feature is flexible and direct.Next, we will discuss how to seamlessly integrate and display the recommended document list closely related to the current document on the document detail page. ### Core Value: Why should recommended documents be displayed on the document detail page?

2025-11-08

How to display the titles and links of the previous and next documents on the document detail page?

In website content operation, it is crucial to provide readers with a smooth reading experience.If a user finishes reading a document and can easily navigate to the previous or next related content, it not only effectively extends the user's stay on the website and increases page views, but also helps search engines better understand the structure and content relevance of the website, thereby having a positive impact on SEO.AnQiCMS (AnQiCMS) has fully considered this point in the design of template functions, providing simple and powerful tags, making it easy to display the title and link of the previous and next documents on the document detail page

2025-11-08