How to get the thumbnail or the first image of the slideshow group in the `pageDetail` tag?

Calendar 👁️ 74

In website operation, well-designed single pages (such as "About Us", "Service Introduction", etc.) are the key to showcasing the brand image and conveying core information.These pages often require rich visual elements to attract visitors, and the effective use of images is an indispensable part of it.For users of AnQiCMS, the ability to flexibly obtain and display the first image from a thumbnail or a slideshow group on a single page is an important capability to achieve this goal.

AnQi CMS provides a powerful template tag system, wherepageDetailThe tag is used to retrieve detailed information about a single page. Through this tag, we can easily access various properties of a single page, including text content, links, and image resources. UnderstandingpageDetailHow to handle the image field will help you control the presentation of page content more accurately.

Get to knowpageDetailLabel and image field

pageDetailThe main function of the tag is to retrieve all related data according to the single page ID or URL alias (token). In terms of image processing, it provides several key fields, includingLogo/ThumbandImagesThey represent different image types for different purposes.

Get the main thumbnail (Logo)

Generally,LogoThe field is designed to store the main thumbnail or a larger cover image for a single page, which you can understand as the page's 'main visual' or 'large thumbnail'. If you upload a 'thumbnail large image' when editing the single page in the background, then throughpageDetailin the labelname="Logo"Parameters can be easily used to obtain the URL of this image.

For example, if you want to display the main thumbnail of the current page in a template, you can write the code in this way:

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

If you need to specify the main thumbnail of a single page for a specific ID (for example, ID 5)idparameters:

{% set mainPageLogo = pageDetail with name="Logo" id="5" %}
<img src="{{ mainPageLogo }}" alt="特定页面的主图" />

In this way, the image will load and display on your page.

Retrieve a standard thumbnail (Thumb)

withLogoThe field is similar,ThumbThe field is used to store the general thumbnail of a single page. It may be a smaller size, faster loading version, suitable for list pages or other scenarios that require small-sized image display.When editing a single page in the background, it corresponds to the 'thumbnail upload option.'

ObtainThumbThe usage of the field is similar toLogoSimilar, just need tonamethe parameter toThumband it is done:

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

Similarly, it can also be done throughidortokenParameter to get the specified pageThumb:

{% set pageThumbnail = pageDetail with name="Thumb" id="5" %}
<img src="{{ pageThumbnail }}" alt="特定页面的缩略图" />

Get the first image in the slide set (Images)

For those pages configured with multiple images as slideshows or carousels, Anqi CMS stores these images inImagesThis field contains. This field returns an array (or list) of image URLs.You can loop through this array to display all the images, but in many cases, we may only need to show the first image as a cover or preview.

To obtainImagesThe first image in the field, you can combine the features of the Anqi CMS template engine, firstImagesAssign the value of the field to a variable, and then get the first image through the array index[0]to obtain the first image.

The following is the method to achieve this goal:

{% pageDetail pageImages with name="Images" %}
{% if pageImages %} {# 检查是否存在幻灯片组图 #}
    {% set firstCarouselImage = pageImages[0] %}
    <img src="{{ firstCarouselImage }}" alt="{% pageDetail with name="Title" %}" />
{% endif %}

This code first usespageDetailObtainImagesField and store the result inpageImagesVariable. Next, throughif pageImagesDetermine if there is a slide image. If it exists, use{% set firstCarouselImage = pageImages[0] %}Assign the first element of the array (i.e., the URL of the first image) tofirstCarouselImagea variable, then display it in a<img>in the tag.

You can also use this image as a CSS background image:

{% pageDetail pageImages with name="Images" %}
{% if pageImages %}
    {% set firstCarouselImage = pageImages[0] %}
    <div class="page-banner" style="background-image: url('{{ firstCarouselImage }}');">
        <!-- 其他页面内容 -->
    </div>
{% endif %}

This method provides you with great flexibility, whether the single-page configuration is a single main image or multiple slides, you can accurately extract and use the required images according to your needs.

Image upload and processing prompt

Please note the following points when using these tags to retrieve images:

  • Backend configuration:Make sure you have uploaded images for the corresponding page in the "Page Management" section of the Anqi CMS backend, and that these images have been associated withLogo/ThumborImagesfield.
  • Automatically extract:If you have not manually uploaded a thumbnail but the single-page content contains images, Anqi CMS may automatically extract the first image in the content according to the settings.
  • Image processing:AnQi CMS provides image auto-compression, WebP format conversion, thumbnail size and processing methods, and other functions in the "Content Settings".These settings will affect the final display effect and loading speed of the image on the front end, and it is recommended to optimize according to the website requirements.

by masteringpageDetailFlexible calls for image fields, your safe CMS website will be able to present visual content better, enhance user experience, and bring more possibilities for website operations.


Frequently Asked Questions (FAQ)

1. If I haven't uploaded any images for the single page,LogoorThumbwhat will the field display?

If the single page hasn't explicitly uploaded 'thumbnail large image' or 'thumbnail', thenLogoorThumbThe field may be empty. However, AnQi CMS usually has an intelligent recognition feature, if the text content of a single page contains images, the system may try to automatically extract the first image in the content as the default thumbnail.It is recommended that you always add a judgment (such as when using these image fields in the template){% if item.Logo %}To avoid the page display error that may occur when the image link is empty, or provide a default placeholder image.

Can I directly obtain the content of a single page (ContentField) pictures?

pageDetaillabel'sContentThe field returns single-page HTML content, which may contain multiple images. To retrieve all the image URLs in this content, you need toContentThe field returns HTML strings that need to be parsed. This usually requires some JavaScript code or more complex backend template processing logic to extract all of the<img>tags and theirsrcProperty. The template tags of AnQi CMS are mainly used to obtain structured field data, and for the deep parsing of internal elements of unstructured content (such as正文HTML), developers need to perform secondary processing.

Why does my uploaded image appear blurry or the wrong size on the website?

This is likely related to the global image processing strategy in the 'Content Settings' of AnQi CMS backend.In the "Content Settings", you can configure whether to automatically compress large images, automatically convert to WebP format, and set the "processing method" (such as scaling proportionally by the longest side, cropping by the shortest side, etc.) and "thumbnail size" of the thumbnails.If your image looks blurry or the size does not match your expectations, please check these settings to ensure they match your website design and display requirements.Sometimes, after changing the settings, you may need to regenerate thumbnails in bulk to apply the new configuration.

Related articles

How to get the thumbnail and background Banner image of the `categoryDetail` tag?

In AnQi CMS, the visual presentation of a website is the key to attracting visitors and conveying the brand image.Category thumbnails and background banners play a significant role in web page design, as they can directly display category content and enhance the aesthetics and user experience of the page.Anqi CMS provides flexible and easy-to-use template tags `categoryDetail`, which helps us easily obtain and display these visual elements.### Understanding the `categoryDetail` tag `categoryDetail`

2025-11-08

How to use the `archiveList` tag to display the thumbnail of each article on the list page?

In Anqi CMS, to make your website's content list page more attractive, displaying an eye-catching thumbnail for each article or product is the key to improving user experience and the beauty of the page.This not only helps visitors quickly understand the content topic, but also effectively improves the click-through rate.AnQiCMS provides an intuitive and powerful template tag feature, allowing you to easily achieve this goal on the list page.### Core Feature Revelation: `archiveList` Tag and Thumbnail The goal to be achieved in AnQiCMS

2025-11-08

What is the difference in fetching images between the `Logo` and `Thumb` fields in the `archiveDetail` tag?

When managing content in Anqi CMS, we often encounter various fields related to images, among which the `Logo` and `Thumb` fields under the `archiveDetail` tag often confuse new users.They all represent images, but there are very clear and practical differences in terms of usage and system processing.Understanding these differences can help us better plan the content of images, improve the loading speed of the website, and enhance the user experience.### `Logo` field

2025-11-08

How to enable the automatic compression of large images in AnQiCMS and specify the compression width?

In website operation, images are the key elements that attract users and enrich content.However, large-sized images, while bringing visual impact, may also become a bottleneck for website loading speed, affecting user experience and even search engine rankings.AnQi CMS knows this pain point, built-in efficient image processing features, including the highly praised "auto-compress large image".This feature is designed to help you significantly optimize website performance and storage space without sacrificing too much image quality. To enable and configure this utility feature, you just need to log in to the Anqi CMS backend management interface.Log in to the background after

2025-11-08

The `thumb` filter can be used to process the image URL obtained from `categoryDetail` or `pageDetail`?

When using the AnQiCMS template, we often encounter the need to handle image links, especially for the display of thumbnails.The system provides multiple ways to obtain images, one common issue is about the combination of the `thumb` filter with the image fields in the `categoryDetail` or `pageDetail` tags.First, let's understand the basic logic of AnQiCMS in image processing.

2025-11-08

In AnQiCMS image resource management, how to replace an image while keeping the original URL unchanged?

In website content operation, images are indispensable visual elements that can effectively enhance the attractiveness and reading experience of the content.However, as the operation deepens, we often need to update the images to reflect the latest products, services, or design styles.

2025-11-08

How to prevent uploading large images from affecting the page loading speed in AnQiCMS?

## Using AnQiCMS, easily say goodbye to large image lag: full analysis of optimization strategies In today's digital age, website loading speed is a key factor in user experience and search engine rankings.Among them, images as an important part of content display are often also the main culprits that slow down the speed of the website.An unoptimized large image not only consumes a lot of bandwidth but also significantly prolongs the page loading time, leading to user loss.

2025-11-08

How to use the AnQiCMS image optimization feature to improve the SEO performance of the website?

In the context of the increasingly important content marketing and search engine optimization (SEO), the quality and optimization of website images have a significant impact on the overall performance of the website.Images not only enhance user experience and make content more attractive, but are also one of the important dimensions for search engines to evaluate website quality.High-quality image optimization not only speeds up page loading, but also helps search engines better understand the content of the image through correct attribute settings, thereby bringing more natural traffic to the website.

2025-11-08