简体   繁体   English

谷歌驱动器带来的图像使页面加载非常慢

[英]Images brought from google drive make page load very slow

I have a webpage with some images I downloaded from google drive using php code: 我有一个网页,其中包含一些使用php代码从Google驱动器下载的图像:

 $albumURL = $url."host/".$fila['album']."/"; @$doc->loadHTMLFile($albumURL); $xpath = new DOMXPath($doc); $anchors = $xpath->query('//a'); $ref=""; foreach($anchors as $element) { $ref = $element->getAttribute("href"); } $first = true; foreach($anchors as $element) { $src = $element->getAttribute("href"); if($src != "http://drive.google.com"){ if($primero){ $first = false; echo '<div class="item active"><img src='.$url.$element->getAttribute("href").'></div>'."\\n"; } echo '<div class="item"><img src='.$url.$src.'></div>'."\\n"; } 

The problem is that when I try to load my page it's very slow, I'm guessing that it is because of the quantity of images I request. 问题是,当我尝试加载页面时,它的运行速度非常慢,我猜这是因为我请求的图像数量大。 Here is a link of my page: http://arreglosnavidad.host22.com/arreglos.php 这是我页面的链接: http : //arreglosnavidad.host22.com/arreglos.php

I don't know if there is any way of compressing those images by using php or html/css. 我不知道是否可以通过使用php或html / css压缩这些图像。

Of course, it would be better if I don't have to upload those images in the server because of the CRUD management.(And to keep them up-to-date) 当然,由于CRUD管理,如果我不必将那些图像上传到服务器中会更好(并保持它们为最新)。

Some options 一些选择

  1. Using CSS Sprites. 使用CSS Sprites。 Instead of loading sending GET request for large quantities images hence increase client to server traffic, you can combine all several images into one big image and use relative position in your div to just display the section or subimage that is part of your consolidated image. 您可以将所有几张图像合并为一个大图像,并在div中使用相对位置以仅显示合并图像的一部分或子图像,而不是加载发送大量图像的GET请求,从而增加客户端到服务器的通信量。

Check this link for this trick 检查此链接此技巧

https://css-tricks.com/css-sprites/ https://css-tricks.com/css-sprites/

  1. Reduce the size of your actual images and set the width and height of you image tag in your html document so that when you image is loaded it will stretch (This affect the quality of your image) 减小实际图像的大小,并在html文档中设置图像标签的宽度和高度,以便在加载图像时它会拉伸(这会影响图像的质量)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM