I have a php
page that has a lot of images. And depending on the client window size the image size changes. For my specific scenario, I need the image width to be exactly the size of the div
it's in (like pixel-to-pixel).
我有一个PHP页面,有很多图像。并且根据客户端窗口大小,图像大小会发生变化。对于我的具体情况,我需要图像宽度恰好是它所在的div的大小(如像素到像素)。
So basically, how do I load the different sizes of the image? I cant create all the possible width's of the image beforehand.
所以基本上,我如何加载不同尺寸的图像?我无法预先创建图像的所有可能宽度。
Is there a way to do this resizing dynamically?
有没有办法动态调整大小?
1 个解决方案
#1
1
For a server running php
, you can use one of these libraries to resize the images on the fly:
对于运行php的服务器,您可以使用其中一个库来动态调整图像大小:
You can install the library using composer by running composer require meenie/munee
or composer require mos/cimage
您可以通过运行composer require meenie / munee或composer require mos / cimage来使用composer安装库
Then you can link your photos by using one of these:
然后,您可以使用以下方法之一链接您的照片:
- Meenie:
<img src="/path/to/image.jpg?resize=width[100]">
- cImage:
<img src="/host/img.php?src=test.png&width=100">
Meenie:
cImage:
#1
1
For a server running php
, you can use one of these libraries to resize the images on the fly:
对于运行php的服务器,您可以使用其中一个库来动态调整图像大小:
You can install the library using composer by running composer require meenie/munee
or composer require mos/cimage
您可以通过运行composer require meenie / munee或composer require mos / cimage来使用composer安装库
Then you can link your photos by using one of these:
然后,您可以使用以下方法之一链接您的照片:
- Meenie:
<img src="/path/to/image.jpg?resize=width[100]">
- cImage:
<img src="/host/img.php?src=test.png&width=100">
Meenie:
cImage: