When operating a website, we all hope to provide visitors with a smooth and pleasant browsing experience.Among them, the loading speed of images and videos and other media resources is undoubtedly a key factor affecting the experience.If the media resources on the page load slowly, visitors may lose patience and even leave directly. 幸运的是,Aqiy CMS was well-thought-out from the beginning of its design, providing various functions and strategies to help us efficiently manage and display these valuable resources.
Firstly, from the perspective of the system's bottom layer, Anqicms is constructed based on the Go language, and this high-performance architecture naturally has high concurrency processing capabilities.This means that even when facing a large number of visitor requests, the website can respond stably and quickly.Moreover, the system also has a built-in static caching mechanism.After the page content (including the links to media resources) is generated, they can be cached.Next time when a user visits, it directly retrieves from the cache, greatly reduces the server's calculation time, thus significantly improves the page loading speed.
However, relying solely on underlying performance is not enough, the optimization of media resources also requires us to carry out fine-grained operations from the content management level. Anqi CMS provides us with very practical media processing functions in the "Content Settings" section of the backend:
Intelligent conversion of WebP image format
Automatically Compress Large Image: Often, the original size of the images we upload may be too large, far exceeding the display size required by the web page.The AnQi CMS has the function of automatically compressing large images, and you can set a pixel value for 'auto-compress to a specified width'.For example, setting it to 800 pixels wide means that all images wider than 800 pixels will be automatically compressed to this width after upload, saving storage space and reducing file size, and further speeding up loading.
Intelligent thumbnail processing: Thumbnail images are often needed in website content lists, and these small images can also slow down loading if their sizes are not uniform or if they are too large.AnQi CMS provides three thumbnail processing methods: 'Scale proportionally by the longest side', 'Fill by the longest side', and 'Crop by the shortest side'.You can choose the most suitable mode according to the design style and requirements of the website and set a uniform thumbnail size.When the document does not have an uploaded thumbnail, the system can automatically extract the first image from the document content as a thumbnail, or use the "default thumbnail" you have set in advance to ensure that all content has a unified visual presentation.
Remote image download: Referencing external images in the article content is a common operation.But if these external image servers are unstable or load slowly, it will directly affect the performance of your website.The "Download Remote Images" feature of AnQi CMS allows you to automatically download and store external images referenced in the content to your own server, thereby gaining complete control over image resources and avoiding loading issues caused by external factors.
It is also crucial to control the quality of media from the source during content creation.When inserting images and videos through the Anqicms rich text editor, it is recommended to choose resources with appropriate resolution and relatively small file size.In the "Image Resource Management" section, we can categorize, batch delete, or transfer all uploaded images and videos, keeping the media library tidy and organized, and it also facilitates the quick reference and search for subsequent content.For video content, if it is not self-hosted, it is recommended to use the embed codes of third-party video platforms such as YouTube, Bilibili, etc., which usually have better loading optimization and global distribution capabilities.
Further, at the template level, AnQi CMS also provides flexible tags and filters to help us fine-tune the display of media. For example, when calling documents or category details,archiveDetail/categoryDetail/pageDetailTags can directly obtain imagesLogo(Large image),Thumb(Thumbnail) andImages(Group image) etc. In the display of theContentfield in the article content, you can uselazy="data-src"This parameter, combined with the front-end JavaScript library, implements image lazy loading.This means that the image will only start loading when the visitor scrolls to the area where the image is located, greatly reducing the pressure of the first load.thumbA filter can dynamically generate thumbnails for any image URL, providing greater flexibility for developers.
Even if you insert special media elements such as mathematical formulas or flowcharts in the Markdown editor, Anqi CMS has taken this into account. Although they are text themselves, they may require additional JavaScript and CSS libraries to display, you canbase.htmlThis common template file header includes these external resources to ensure they are rendered correctly and efficiently.
We can also combine a broader network infrastructure to further improve loading efficiency. Consider usingCDN (Content Delivery Network).CDN distributes website static resources (including images, videos, CSS, and JS files) to server nodes around the world. When users access the site, they can retrieve resources from the nearest node, significantly reducing transmission distance and time.In addition, for server-side configuration, whether it is Nginx or Apache, it can be配合 with the operation of Anqi CMS, through the setting of reverse proxy and further cache rules, to optimize the transmission efficiency of media resources.
By means of the above multi-level optimization strategies, from system architecture to background configuration, to content creation and template calling, Anqi CMS has built for us an efficient and smooth media loading and display environment, ensuring that the website can stand out in the fierce online competition.
Frequently Asked Questions (FAQ):
Q: Will the previously uploaded JPG or PNG images be automatically converted after enabling the WebP image format?A: By default, enabling WebP will automatically convert only new uploaded images to WebP format.If you want to convert the previously uploaded images to WebP as well, you can find and use the 'Batch regenerate thumbnails' feature on the 'Content Settings' page, which will convert all existing images (including thumbnails and full-size images) to WebP according to the new settings.
Q: How can I implement lazy loading for images in the article content?A: The Anqi CMS template tags support lazy loading attributes. When you call the article content field in the template (for example
archiveDetaillabel'sname="Content"parameters) you can add extra attributes. For example:lazy="data-src"such attributes. For example:{% archiveDetail articleContent with name="Content" lazy="data-src" %}{{articleContent|safe}}. Then, you also need to introduce a JavaScript library that supports lazy loading of properties to activate this feature.data-srcA JavaScript library for lazy loading properties to enable this feature.Q: Does AnQi CMS automatically handle the image size when displaying thumbnails in the article list?A: Yes.When you configure the "thumbnail size" and "thumbnail processing method" in the background "content settings", the system will automatically generate small images that meet the requirements.
{{item.Thumb}}Call these pre-processed thumbnails without worrying about inconsistent image sizes or large file sizes.