基于 ruby​​ 的服务器的自适应图像 [英] Adaptive images for ruby based servers

查看:41
本文介绍了基于 ruby​​ 的服务器的自适应图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据用户屏幕的大小向客户端发送图像,例如如果我有高分辨率图像,而用户想在移动设备上查看我不想发送全高清图像图像,而不是我想发送缩小到用户设备尺寸的图像,这将提高低带宽设备的加载速度

I'd like to deliver images to client based on the size of the user screen, as in If I have High resolution image, and the user want to view it on a mobile I don't want to send the full HD image, instead I'd like to send the image shrinked to the user's device dimension which will increase the loading speed on low bandwidth devices

此处

自适应图像检测您的访问者的屏幕大小,并自动创建、缓存和提供适合设备的网页嵌入 HTML 图像的重新缩放版本.它旨在与响应式设计一起使用并与流体图像技术结合使用.(来自给定的链接)

我看到了 php 的这种解决方案 &基于 apache 的服务器,是否有针对具有基于 ruby​​ 的服务器的 Web 应用程序的解决方案?gem 可能是...谢谢

I see solutions of this kind for php & apache based servers, is there a solution for the web application which have ruby based servers ? a gem may be... Thanks

推荐答案

媒体查询仅适用于 CSS 背景图像.

Media queries would only work with CSS background images.

顺便说一下,Adaptive-Images 之类的解决方案并不难实现.

By the way Adaptive-Images like solution aren't that difficult to implement.

它们只是代替网络服务器动态提供图像,缓存经过调整的图像以加快处理速度并避免浪费资源.

They just serves images dynamically in place of the web server, caching adapted images to speed the process up and avoiding to waste resources.

根据保存请求设备分辨率的 cookie 的值调整图像大小和缓存.

Images are resized and cached depending on the value of a cookie that holds the requesting device resolution.

假设您在使用 Rails,请执行以下步骤:

Saying that you're in Rails, take the following steps:

  1. 将此 javascript 行附加到布局中的 部分:

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆