如何使用原始照片的其他较小变体存储相同的图像
我正在使用 jQuery fancybox插件效果很好。问题是我不喜欢在页面上加载原始图像及其大小的事实。我需要以某种方式在页面加载上加载此图片的较小变体,然后单击以显示原始图片。在花哨的盒子方面,这很容易做到。但是,较小变体的存储过程使我感到困惑。上传时,我将存储2个图像 - 原始图像和调整大小(较小的变体)。包含照片的较小变体的div
设置为max宽度:500px; max-height:150px;
,这就是如何调整较小的变体照片的大小。 。 500px的最大宽度
和150px的最大高度
。另一个问题是如何保存图像的纵横比?我将如何确定是否需要存储第二张(较小)的照片。我很困惑。我在等你回复。提前致谢。
较小的变体
原始变体 -Fancybox打开
我正在使用图像干预。
我的项目在 Laravel 8 上。
I'm using jQuery Fancybox Plugin which works pretty good. The problem is that I don't like the fact that on page load the original image with its size is loaded. I need to somehow load a smaller variant of this picture on page load and when clicked to show the original one. It's very easy to do when it comes to fancybox. But the storing process of the smaller variant is confusing me. On upload, I'll store 2 images - the original, and the resized (smaller variant) one. The div
that is containing the smaller variant of the photo is set to max-width:500px;max-height:150px;
and that's how the smaller variant photo should be resized. Max width of 500px
and Max height of 150px
. Another question is how will I save the aspect ratio of the image? And how will I determine whether there is a need to store a second (smaller) photo at all. I'm so confused. I'm waiting for you replies. Thanks in advance.
smaller variant
original variant - fancybox opened
I'm using Image Intervention.
My project is on Laravel 8.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您需要在存储空间中存储2个图像。
您需要定义图像的宽度或高度与主纵横比。查看我个人喜欢Spatie Media软件包的以下代码
(在后面使用图像干预)。它使用多态关系在单独的表上处理媒体。
看看文档,令人惊讶
https://spatie.be/spatie.be/docs/laravel/laravel -Medialibrary/V10/简介
Yes, you need to store 2 images on your storage.
You need to define either width or height to main aspect ratio of the image. Check the below code
I personally like spatie media package (Which uses image intervention in behind). It handles media on separate table using polymorphic relation.
Have a look into the docs, it's amazing
https://spatie.be/docs/laravel-medialibrary/v10/introduction