How to automatically compress images based on size and display them on the front-end?

Calendar 👁️ 76

In website operation, images are an important element to attract visitors and convey information.However, large, unoptimized images often become the 'killer' of website loading speed, not only affecting user experience but also possibly dragging down search engine rankings. 幸运的是,AnQiCMS in the field of image processing provides very intelligent and practical functions, which can help us easily cope with these challenges, making images display clearly and quickly on the front-end.

Intelligent compression, say goodbye to the trouble of manually adjusting large images

Have you also encountered such a situation: in order to maintain image quality, you directly uploaded large-size images given by the camera or the designer, resulting in the website page loading as slow as a snail?The AnQi CMS is very considerate in dealing with this issue. It has built-in features for automatically compressing large images, which optimizes the images we upload in the background without affecting the front-end display.

To enable this feature, we just need to go to the background and find“Global Settings”below"Content Settings". Here, you will find an option named"Should large images be automatically compressed". After checking it, you can further set it up“Automatically compress to the specified width”. For example, if you set the width to800像素Then, for all images uploaded, as long as the width exceeds 800 pixels, the system will adjust the width to 800 pixels while ensuring the image perception, and accordingly reduce it proportionally to greatly reduce the image volume.

This means that even if you upload a large image with thousands of pixels, the system will quietly process it into a size more suitable for web display, without the need for you to manually adjust it with tools like Photoshop.This not only saves server storage space, but also significantly improves page loading speed, allowing visitors to see beautiful image content without long waiting.

Flexible thumbnail generation and management

In addition to the automatic compression of large images, the Aiqi CMS also handles thumbnails with great professionalism. In the same"Content Settings"page, you will see“Thumbnail processing method”and“Thumbnail size”. These settings allow us to flexibly generate and call different sizes of images according to the needs of different areas of the website.

AnQi CMS provides three thumbnail processing methods to meet various design needs:

  • Scale proportionally to the longest sideThis method maintains the original aspect ratio of the image, scaling the longest side to the specified size, and the other side is scaled proportionally. This is the most commonly used method and can retain the image content to the maximum extent possible.
  • Fill the longest sideIf you need a fixed-size thumbnail but also want to display the entire image content, you can choose this method.The system will resize the image proportionally to fit the size, and the insufficient part will be filled with white (or a configurable color) to center the image.
  • Trim according to the shortest edgeWhen you want to make sure that the image fills the entire area in a list or grid, this method is very practical.The system will crop the shortest side to the specified length based on the center of the image, which may cut off part of the image edge.

Define these rules and the system can intelligently generate and display thumbnails of corresponding sizes when calling images in the front-end template. For example, you may need to call thumbnails in article lists or product display pages, just use something like{{ item.Logo|thumb }}Such a template tag, or directly call as{{ archive.Thumb }}Such a field, the system will automatically output the image address processed according to the rules you set.

Additionally, if your website needs a unified style, or if some images do not have a separate thumbnail set, "Default thumbnail"The function can be put to use, allowing all missing thumbnail positions to have a unified placeholder. If you adjust the thumbnail settings halfway through,“Batch regenerate thumbnails”The feature can help you update all existing image thumbnails with one click, saving a lot of repetitive operations.

Upgrade Experience: WebP Image Format

Do you want to load images faster while not losing too much quality?WebP is the ideal choice. WebP is an image format developed by Google, which is usually smaller than JPG or PNG image files, but can maintain similar, if not better, visual quality.

In"Content Settings"In, you can enableWhether to enable Webp image format. Turn on this option and new uploaded JPG, PNG and other image formats will be automatically converted to WebP format for storage and display.This means that your website images will load in smaller size, further enhancing the website's response speed and user experience.

In general, Anqi CMS provides a smooth workflow for image optimization.You just need to make a simple configuration in the background, then upload the pictures as usual, and the system will automatically complete subsequent tasks such as compression, cropping, format conversion, etc., so that the image display on the front end of the website is fast and beautiful, thus providing visitors with a better browsing experience and indirectly helping the website's SEO performance.


Frequently Asked Questions (FAQ)

Q1: Will all the images I upload to AnQi CMS be automatically compressed?A1: Not all images will necessarily be compressed. If the original width of your image exceeds the"Content Settings"you have set in“Automatically compress to the specified width”And you have checked to enable it"Should large images be automatically compressed"Then the system will automatically compress it. In addition, whether the original large image is compressed or not, the system will always compress it according to your settings“Thumbnail size”and“Thumbnail processing method”Generate thumbnails of different sizes automatically for the front-end to call.

Q2: How can I display images of different sizes on the front-end page or call compressed images?A2: You can directly call in the template like{{archive.Logo}}or{{item.Logo}}Get the original image address (if automatic compression is enabled, this is the compressed address). If you need to call a specific thumbnail size, please use{{item.Logo|thumb}}This kind of filter. The system will"Content Settings"The thumbnail rules configured, automatically generate and provide the image address of the corresponding size.Thus, you can flexibly display pictures of different sizes according to different scenarios such as article detail pages, list pages, special theme pages, etc.

Q3: Will the existing images on the website be automatically converted to WebP after enabling the WebP image format?A3: Enable WebP format after, only youNew uploadAn image will be automatically converted to WebP format. For images that have already been uploaded, they will remain in their original format.If you want these old images to also be converted to WebP, Anqi CMS provides'Webp conversion tool'(Can be found on the "Content Settings" page, or accessed through other paths), you can use this tool to batch convert all the images on the site to WebP format.

Related articles

How to batch generate and display images in Webp format in AnQi CMS?

Website performance is one of the key factors that determine user experience and search engine rankings.Among various optimization methods, image optimization plays a vital role.WebP is a modern image format that boasts excellent compression performance and almost lossless visual quality, and is gradually becoming the new standard for website optimization.How can we efficiently generate and display WebP images in the Anqi CMS management website?AnQi CMS provides very convenient and powerful functional support in this aspect, allowing you to easily achieve the WebPization of website images without delving into technical details

2025-11-08

How to truncate long text content and display an ellipsis?

In the operation of daily websites, we often encounter such situations: the content of the article detail page is rich, but the list page or recommendation module needs to display a concise version of the content for the sake of page layout, usually by truncating a part of the text and adding an ellipsis at the end.AnQi CMS understands the importance of content display and provides very convenient and powerful tools to handle such needs.Let's take a look at how to elegantly implement the truncation of long text content and display an ellipsis in Anqi CMS, making the website interface both beautiful and professional.The need and value of content truncation in many display scenarios

2025-11-08

How to avoid XSS attacks and safely display HTML content when outputting?

In website content management, ensuring the safe display of information, especially in preventing cross-site scripting (XSS) attacks, is an important issue that every content creator and website administrator must face.XSS attacks exploit vulnerabilities in websites, injecting malicious code into web pages. When other users visit the web page, the malicious code will execute on the user's browser, potentially stealing user information, hijacking sessions, or even tampering with web content, posing serious harm to the website and users.Fortunately, AnQiCMS has fully considered content security from the beginning of its design, providing us with multiple protective measures

2025-11-08

How to configure URL rewrite rules in AnQi CMS to optimize link display?

The website link, like the door number of a website, a clear and regular door number is not only convenient for visitors to remember and share, but also a key to understanding the structure of the website content, improving the efficiency of inclusion and ranking for search engines.This technique of optimizing dynamic links to look like static files is called 'pseudo-static'.The Aanqi CMS thoroughly understands this, providing users with powerful and flexible static configuration capabilities, aimed at helping websites perform better in search engines while improving the user browsing experience.The value of pseudo-static: Why can't it be ignored?in website operation

2025-11-08

How to configure and display thumbnails with different processing methods (such as cropping, scaling)?

##驾驭安企CMS缩略图:精细化的配置与灵活的展示,打造视觉冲击力 在网站运营中,图片无疑是吸引用户、提升内容质量的关键元素。While thumbnails, as the first visual touchpoint of website content, their display effect directly affects users' desire to click and the overall beauty of the page.AnQi CMS knows this and provides us with flexible thumbnail configuration and display capabilities, helping us easily manage and present high-quality image content.### Core Configuration

2025-11-08

How to display detailed information of the currently logged-in user (such as username, avatar, VIP status)?

In Anqi CMS, displaying the detailed information of the currently logged-in user, such as username, avatar, and VIP status, is a key step to enhance user experience and build a personalized website.AnQi CMS with its flexible template engine allows us to easily implement these features.This article will introduce how to display this information on your website front-end. ## Retrieve basic information of the currently logged-in user The Anqi CMS template system provides the `userDetail` tag, which is the core tool for retrieving various information of the currently logged-in user.This tag can directly retrieve the user data of the current session

2025-11-08

How to display the names and introduction information of different user groups?

Displaying different user group names and introduction information in AnQi CMS is an important part of website personalized operation and content distribution.Whether you want to display exclusive identification for VIP members or provide customized content for users with different permissions, Anqi CMS's flexible template tag system can help you easily achieve this. ### Understanding the Core Concepts of User Group Information To display the name and introduction of the user group, it is first necessary to clarify two key points: whether the user is logged in, and which user group the user belongs to. Safe CMS provides powerful template tags

2025-11-08

How to conditionally display different content or styles within a loop?

In website content display, we often encounter the need to display different content or assign unique styles to elements according to the order of data cycles, specific attributes, or states.For example, odd and even rows in the list need different background colors, special markings for certain types of products, or when a field is empty, hide the corresponding area.With its flexible and powerful Django-like template engine, AnQi CMS makes these requirements simple and easy to implement.By cleverly combining loop tags (`{% for ... %}`) and conditional judgment tags (`{% if ... %}`)

2025-11-08