Problem/Motivation
Previously, using the core rendering of #attached properties, you had the option of defining attributes on the element, which would be added to the tag. The "media" key for css elements is one such example. This would end up being rendered as a
element with media= attribute which could be used to define media queries in CSS. The bg_image_formatter module uses this method to provide responsive background images. I am trying to adapt that module to use the Attach Inline framework for rendering its inline css. However, these are dropped. How did core do this?Steps to reproduce
I am using an experimental branch of bg_image_formatter, I can push that in a bit.Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | attachinline-render_media_query-3167803-3.patch | 1.5 KB | bburg |
Comments
Comment #2
bburgSo this seems to only need two tweaks,
1, Actually set the media element in CssCollectionRendererDecorator
2, Hash the entire $options array in AssetResolverDecorator, because it seemed to be overwriting styles that were duplicative, though legitimate breakpoints. For example, if one were being lazy and using the same image style for mobile and tablet:
The second would overwrite the first, and then the mobile layout wouldn't get a style.
Patch coming.
Comment #3
bburgComment #4
gappleI think it would be better to allow a whole
attributesarray, and not justmedia.As far as I can tell, the array key isn't meaningful, so
'attachinline-' . count($css)would work fine, instead of serialize + hash.Comment #5
bburgI was following the example of CssCollectionRenderer which seems to hard code references to those attributes. Without digging into the DTD, I'm not sure what else a style tag would need besides perhaps the global attributes.
Whichever works for the hash, I I liked it as it seems to avoid any potential clashes pretty well. But I can see a lot of those being a performance hit.
Comment #7
gappleThis now works in 8.x-1.2
Comment #8
gapple(Also note that if you're testing nonces, the config option was renamed)