Re: Background image cropping

On Jun 11, 2014, at 5:11 PM, Marat Tanalin <mtanalin@yandex.ru> wrote:

> 11.06.2014, 04:52, "Sylvain Galineau" <galineau@adobe.com>:
>> On Jun 10, 2014, at 5:30 PM, Marat Tanalin <mtanalin@yandex.ru> wrote:
>>>  Media Fragments could be used in CSS for some simplest cases, while pure-CSS solutions could be used as a more flexible and usable alternative when needed.
>>> 
>>>  For example, how would following expression be expressed in terms of Media Fragments?
>>> 
>>>     /* Here we have 4em-size center part of the image: */
>>>     -moz-image-rect(
>>>         calc(50% - 2em),
>>>         calc(50% - 2em),
>>>         calc(50% - 2em),
>>>         calc(50% - 2em)
>>>     )
>> 
>> In cases like this you'd need the full image to compute the result anyway, so it's not really a scenario for MF.
>> 
>> This thread started with background sprites as they are currently built on the web. Those can certainly use MF, though some syntactic sugar to build the fragment may be nice...
> 
> Based on whay you say, it looks like that Media Fragments cause a separate HTTP request for each region of the same image (one image => multiple HTTP requests).

Browsers separate the image source from the media query. It is unlikely that you get multiple requests with one image just because you use different media fragments.

Also, media fragments don’t just affect CSS. They can be used with HTML’s <img> tag and SVG’s <image> element and in theory even with <video> and <audio>. What I mean with that: It is a good idea to have a solution that fits many use cases. Especially when the feature is that simple.

Yes, you can not use calc() in CSS but can’t in Media Fragments. So far I did not see a good use case where you want to do that. Most of the time you have an intrinsic size and the crapped content is at a certain position. However, the responsive images user group is experimenting with intelligent content fitting solutions. Maybe you want to get involved in this topic?

Greetings,
Dirk

> 
> This is the contrary to the main idea behind sprites that consists of uniting multiple images into a single image file to _minimize_ the number of HTTP requests (multiple images => one HTTP request).
> 
> If so, MF look like not suitable for the purpose of spriting at all.

Received on Wednesday, 11 June 2014 15:35:47 UTC