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?


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",-> = "auto #{@.height}px"


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",-> = "auto #{@.height}px"

Stefan Hvlmnns

great thx!

Jordan Robert Dobson

There is a utility for document ready.

Read the entire post on Facebook