[英]Image resizing for mobile site, Ruby on rails
so I am working on a website that is a static scrollable one page, but for some reason it was deployed in ruby on rails. 所以我在一个静态静态可滚动页面的网站上工作,但是由于某种原因,它已部署在Rails中的ruby中。 I am a noob in ror.
我是ror的菜鸟。 There is one image in the html page that needs to resize whenever the site is loaded on a mobile device.
html页面中只有一张图片,无论何时将网站加载到移动设备上,都需要调整大小。
<li><%= image_tag 'Main_logo.png', width: '700', height: '399' %></li>
Now I think I can do this in CSS, which means the client will resize and the full size image will always be downloaded. 现在,我想可以在CSS中执行此操作,这意味着客户端将调整大小,并且始终会下载完整尺寸的图像。 My question is how can I solve this issue using ror?
我的问题是如何使用ror解决此问题? I am sure ruby on rails has some server side capacity to fix this.
我敢肯定,Ruby on Rails可以解决此问题。 Keep in mind I am new to ruby on rails
请记住,我是刚接触红宝石的人
Thanks. 谢谢。
To your problem of resizing images, you can use the gem rmagick
( https://github.com/rmagick/rmagick ) 对于调整图像大小的问题,可以使用gem
rmagick
( https://github.com/rmagick/rmagick )
The key line you probably need is thumb = img.resize_to_fit(75, 75)
, and the document explaining it well is at http://www.imagemagick.org/RMagick/doc/comtasks.html 您可能需要的关键行是
thumb = img.resize_to_fit(75, 75)
,有关它的很好解释的文档位于http://www.imagemagick.org/RMagick/doc/comtasks.html
To your problem of detecting mobile browsers: SO post Detecting mobile browsers in Rails 3 对于您检测移动浏览器的问题:SO post 在Rails 3中检测移动浏览器
Or if you want a super quick and dirty way, you can paste this into your controller: http://detectmobilebrowsers.com/ 或者,如果您想要一种超快速且肮脏的方式,可以将其粘贴到您的控制器中: http : //detectmobilebrowsers.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.