Unfortunately Slimmage does not support background images, you see a thread here and a useful link to how to support responsive background images using media queries.
You could of course use the native GetCropUrl method to generate the url of your background image.
<div class="section top header_anim" style="background-image: url('@featureImage.GetCropUrl(1200,1200)')">
Note: this requires that @featureImage is strongly typed (Umbraco.TypedMedia) rather than dynamic (Umbraco.Media)
On further thing, GetResponsiveImageUrl requires two parameters, if you want a flexible height just pass in 0, e.g. GetResponsiveImageUrl(1200,0)
Background-Image problems
Hi there
I'm having a little problem with your nice tool.
I'm trying to do this:
<div class="section top header_anim" style="background-image: url('@featureImage.GetResponsiveImageUrl(1200)')">
But it add's this in the source code:
<img data-src="/media/1001/top banner.jpg?anchor=center&mode=crop&quality=90&width=270&heightratio=0.5962962962962962962962962963&slimmage=true&rnd=130485982960000000" alt="" data-slimmage="true" src="/media/1001/top banner.jpg?anchor=center&mode=crop&quality=90&width=2080&heightratio=0.5962962962962962962962962963&slimmage=true&rnd=130485982960000000" data-pixel-width="2080">
And places the tag in the wrong place.
Does it only work for the <img> tag?
Hi Søren,
Glad you like Slimsy :-)
Unfortunately Slimmage does not support background images, you see a thread here and a useful link to how to support responsive background images using media queries.
You could of course use the native GetCropUrl method to generate the url of your background image.
Note: this requires that
@featureImage
is strongly typed (Umbraco.TypedMedia
) rather than dynamic (Umbraco.Media
)On further thing,
GetResponsiveImageUrl
requires two parameters, if you want a flexible height just pass in 0, e.g.GetResponsiveImageUrl(1200,0)
Jeavon
Thanks Jeavon
I am not sure Media Queries is the way forward, because the background image is an Umbraco image, that changes from page to page.
I need a user selectable from umbraco responsive image, was hoping your tool could do that.
Adding the possibility to handle background-image would be real nice.
But i'll of cource still use the tool for every other image on the webside :)
Have a nice weekend
Cool, I would use
GetCropUrl(1200)
for the background then :-) FYI:GetCropUrl
can accept a single width parameter without a height.p.s Have you seen my uHangOut about the Image cropper and Slimsy? If not it's here
I'll watch the hangout straight away :)
FYI,
For those interested, I have a pending pull request for a background image plugin for slimmage. I needed it to get the grid BG images responsive.
https://github.com/imazen/slimmage/pull/57
Thanks, Jason
Super cool Jason!
is working on a reply...