This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Stefan Hvlmnns
Posted Jan 26 - Read on Facebook

maybe a dumb question, but how can i set an image to auto height?

Solution:

link = "yourimage.jpg"

image = new Layer
____superLayer: scroll.content
____width: Framer.Device.screen.width
____height: Framer.Device.screen.height
____html: "<img class='import-image' src='#{link}' style='height:auto;width:100%;'>"

image.on "change:size",->
____image.style.backgroundSize = "auto #{@.height}px"

12 Comments

Remco Bakker

I'm a noob, but try height 100%

Stefan Hvlmnns

strings are not allowed :)

Stefan Hvlmnns

also i guess framers has nothing like document ready

Stefan Hvlmnns

since my image always has an height of 0

Remco Bakker

What if you do something like javascript's viewport.height

Remco Bakker

Is there something like that in framer?

Stefan Hvlmnns

don't need the viewport

Stefan Hvlmnns

this is my current code. i just need to set the height of the image layer to the height of the image

Stefan Hvlmnns

but since framer gets not executed when the document is ready but before, the image has a height of 0

Marc Krenn

I'd try something like this:

layer.on "change:size",->
_____layer.style.backgroundSize = "auto #{@.height}px"

https://developer.mozilla.org/en-US/docs/Web/CSS/background-size

Stefan Hvlmnns

great thx!

Jordan Robert Dobson

There is a utility for document ready.

Read the entire post on Facebook