How to display detailed information of image resources on the front page, such as file name, size, and image address?

Calendar 78

When using AnQiCMS to manage website content, images are undoubtedly an important element in enhancing page attractiveness.We often need to display not only the image itself on the front-end page, but also further details about the image, such as their filenames, sizes, and storage addresses.This is very helpful for visitors to understand the background of the image, to make content references, or to manage and download images and other operations.

AnQiCMS as an efficient and flexible content management system provides convenient image upload and management functions.The Image Resource Management page (usually under "Page Resources" -> "Image Resource Management") displays detailed information for each image, including filename, file type, upload time, file size, image resolution, and image address.This information is clearly visible in the background, then how can we present these valuable data on the front-end page?

How to display basic information (URL) of pictures on the front page of AnQi CMS

Firstly, the most fundamental and core is the display of the image on the front.Whether it is an article, product, or single-page, we usually use images as thumbnails, cover images, or illustrations in the content.AnQiCMS provides the corresponding template tags to obtain the URL addresses of these images.

For example, in the details page of a document (article or product), if the document is set with a thumbnail, we can usearchiveDetailLabel to get the image address:

{# 假设我们正在一个文档详情页,获取文档的封面首图URL #}
<img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />

{# 如果需要获取文档内容的缩略图,可能是这样 #}
<img src="{% archiveDetail with name="Thumb" %}" alt="{% archiveDetail with name="Title" %}" />

If the image is part of a multi-image group (such as a carousel or gallery), we can iterate overImagesfield to get the URL of each image:

{# 假设我们在一个页面,获取其设置的Banner组图 #}
{% pageDetail pageImages with name="Images" %}
<ul>
  {% for item in pageImages %}
  <li>
    <img src="{{item}}" alt="页面名称" />
    {# 在这里,{{item}}就是每张图片的URL地址 #}
  </li>
  {% endfor %}
</ul>

By these tags, we can easily display images on the front-end page, and{{item}}or{% archiveDetail with name="Logo" %}The output is the complete access address of the image on the server.

Further: Display image filename, size and resolution

The AnQiCMS backend "Image Resource Management" interface indeed displays detailed metadata for each image, such as filename, size, and resolution. However, on the frontend template tag level, for images passed throughLogo/ThumborImagesThe image URL obtained from the field, the system does not provide direct labels to output these detailed metadata by default.This is because when the front-end renders the page, it usually focuses more on the display and loading speed of the image itself, and the direct output of image metadata is not necessary in all scenarios.

However, this does not mean that we have no way out. We can consider the following strategies:

1. Display the image address (URL)

As mentioned earlier,{{item}}or{% archiveDetail with name="Logo" %}The tag directly outputs the image URL. It inherently contains the 'address' information of the image on the website.

{# 在图片下方显示其URL地址 #}
<div>
  <img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />
  <p>图片地址:<span>{% archiveDetail with name="Logo" %}</span></p>
</div>

2. Display image file name (via custom field or frontend parsing)

  • Through custom content model field:This is the most recommended and reliable method.If you want to display the original file name of the image on the front end, you can add a custom field in the AnQiCMS content model.For example, in the "Article Model" or "Product Model", in addition to the existing "Thumbnail" field, a text field for "Original Filename" can be added.

    1. Go to the background "Content Management" -> "Content Model".
    2. Select the model to be modified (such as "article model
    3. In the "Content Model Custom Field", add a new field, such as "Parameter Name" set to "Original Filename","Callee Field" set tooriginal_filenameChoose "Single-line text" for the field type.
    4. Save model settings.
    5. When publishing or editing an article, manually enter or copy the original filename of the image into this new field.

    After that, in the front-end template, it can be displayed like calling other custom fields:

    {# 假设我们在文章详情页,且已设置自定义字段 original_filename #}
    <div>
      <img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />
      <p>图片地址:<span>{% archiveDetail with name="Logo" %}</span></p>
      <p>原始文件名:<span>{% archiveDetail with name="original_filename" %}</span></p>
    </div>
    
  • Parse the URL through front-end JavaScript:If you do not want to add custom fields, you can also consider extracting the filename from the image URL using JavaScript on the front end.But this can only extract the filename part from the URL path, and cannot retrieve the original filename at the time of upload (if the server has renamed the filename).

    <img id="myImage" src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />
    <p>图片地址:<span id="imageUrl"></span></p>
    <p>文件名:<span id="imageFilename"></span></p>
    
    <script>
      document.addEventListener('DOMContentLoaded', function() {
        const imageUrlElement = document.getElementById('imageUrl');
        const imageFilenameElement = document.getElementById('imageFilename');
        const imgElement = document.getElementById('myImage');
    
        if (imgElement && imgElement.src) {
          const fullUrl = imgElement.src;
          imageUrlElement.textContent = fullUrl;
    
          // 从URL中提取文件名
          const filename = fullUrl.substring(fullUrl.lastIndexOf('/') + 1);
          imageFilenameElement.textContent = filename;
        }
      });
    </script>
    

3. Display image size and resolution

AnQiCMS's front-end template tags do not directly provide the functionality to obtain the size and resolution of image files. This information is usually obtained through JavaScript after the image has been loaded (for example, by using Imagethe object'snaturalWidthandnaturalHeightProperty to get resolution), or they can be pre-stored in custom fields when processed on the server.

  • Front-end JavaScript to get resolution:

    `html <img id="myImageRes">

Related articles

How to display specific content or member permission prompts for different user groups on the front page of Anqi CMS?

In website operation, providing differentiated content or services for different user groups is an important strategy to enhance user experience and achieve content monetization.AnQiCMS (AnQiCMS) understands this need, built-in powerful user group management and VIP system, allowing you to easily implement personalized content display and permission control on the front page. ### Flexible User Groups and Permission System One of the core strengths of Anqi CMS is its flexible user group and VIP system.In the background, you can create multiple user groups, such as "Regular User", "Registered Member", "VIP Member"

2025-11-09

How to batch regenerate the thumbnails of AnqiCMS to adapt to the new display size requirements of the front page?

The display effect of image materials is crucial during website operation.Sometimes, due to website template updates, design style adjustments, or considerations for optimizing performance, the front-end page of the website may require new display sizes for image thumbnails.In this case, how can a large number of images uploaded to AnqiCMS (AnqiCMS) be generated into appropriate thumbnails according to new size requirements, rather than manually processing one by one, which has become a concern for many users.AnqiCMS fully considers the actual needs of content operators and built-in convenient thumbnail batch processing function

2025-11-09

How to configure the image processing method (Webp, compression, thumbnail) in AnqiCMS content settings to optimize front-end loading speed and display quality?

In the era where content is king, the loading speed and display quality of website images have a significant impact on user experience and search engine optimization (SEO).High-quality images, if they load slowly or are blurry, not only may deter visitors, but may also affect the website's ranking in search engines.Luckily, AnqiCMS provides a series of powerful and flexible image processing features to help us easily meet these challenges.Next, we will delve deeper into how to cleverly configure the image processing method in AnqiCMS content settings, including WebP

2025-11-09

How to display friendly information to users on the front end during the website maintenance period of AnqiCMS's 'Shutdown Prompt' feature?

In website operations, we all understand the importance of maintenance work.Whether it is system upgrade, data migration, or solving emergency faults, the website will always have a period of time when it has to be "offline".However, how to ensure the smooth progress of maintenance work during this special period, while minimizing the impact on user experience and not damaging the professional image of the website, this is indeed a problem worthy of deep thought.The "Shut Down Prompt" feature of AnQiCMS (AnQiCMS) is specifically designed to address this pain point, allowing us to communicate information to the front desk users in a friendly and clear manner

2025-11-09

How to determine whether a string, array, or object in AnqiCMS template contains a specific keyword and display content dynamically based on this?

In AnqiCMS, flexibly judging and dynamically displaying information based on content is the key to improving website user experience and SEO effects.Imagine that your website can automatically display related purchase links based on whether an article mentions a specific product; or recommend different sidebar content based on the category the user is in.This not only makes your website smarter, but also greatly improves the efficiency of content operation.The AnqiCMS template engine provides powerful features to help you easily implement these dynamic logic.

2025-11-09

How can I truncate a string or HTML content in AnqiCMS template and add an ellipsis to control the display length?

In website operation, the way content is presented has a crucial impact on user experience and information transmission efficiency.Whether it is the introduction of the article list, the abstract of the product description, or other text content that needs to be previewed, reasonable control of the display length and the use of ellipses can not only maintain the page's neat and beautiful appearance, but also guide users to click and view more details.AnqiCMS as an efficient and flexible content management system, provides a variety of powerful template tags and filters, making the control of content length extremely simple and intelligent.Why do we need to truncate content and add an ellipsis

2025-11-09

How to automatically parse a URL string into a clickable a tag in AnqiCMS template for convenient browsing?

When operating a website, we often add some URLs in articles, product descriptions, or single-page content, which may be recommended external resources or references to other content within the site.But if these URLs are just displayed in plain text, users will have to copy and paste to access them, which is inconvenient and also affects the reading experience.AnqiCMS has fully considered this point and provided us with a very convenient way to automatically convert plain text URLs in the content into clickable links, greatly enhancing the convenience of user browsing and the professionalism of the website.

2025-11-09

How to display traffic or crawler access data charts on the front end of AnqiCMS's background data statistics function?

Understanding website traffic and user behavior is crucial for operators.AnqiCMS as an efficient enterprise-level content management system provides detailed data statistics and crawling monitoring functions in the background.This data can not only help us analyze the performance of the website and optimize the content strategy, but also has the potential to provide more intuitive information to users or visitors in specific scenarios through the display of charts on the front end.

2025-11-09