Dynamic image resizing in the Cloud for Responsive website

扶醉桌前 提交于 2019-12-07 15:16:32

You should check out WURFL Image Tailor. Works pretty much as you describe. You refer the images through a proxy like this:

    <img src="//wit.wurfl.io/[full-url-to-your-image]">

The proxy will then detect the screen size of the user-agent and resize the image accordingly. This service also take some arguments that allows you to explicitly set height, width and percentage of screen size.

Lilith River

There are many such services, and a similar question has been asked before.

All reliable solutions will also requires a tiny bit of client-side javascript. Cookies don't work on the first page load (which is most of them), and sniffing gives useless data if you're doing RWD with breakpoints. Excepting slimmage (and solutions with <noscript> tags), most will download 2 copies of each image (or worse, fail accessibility and SEO requirements).

I favor the DRY & CSS-friendly Slimmage.js, as its author, but there is also Picturefill for those who want art direction support (and are willing to handle the resulting markup complexity). Both can be used with any RIAPI-compliant server-side module, such as ImageResizer (disclaimer of authorship applies here too).

If you have access to a Windows (or linux/mono) server, consider self-hosting.

Dynamic imaging SaaS products appear and fail on a regular basis, so have a backup plan in place to replace the URLs if your SaaS isn't RIAPI-compliant. If your HTML isn't dynamic or can't be post-processed, you're going to have... fun.


A few services (free or in beta):

Some non-free (and non-compliant) services

One image resizing service you can use is https://gumlet.com. You can use any image source with it and resize images exactly as per your need.

For example, to get image width of 300 px, you can write

https://subdomain.gumlet.com/image.jpg?width=300

P.S. I work at Gumlet.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!