francoischalifour / medium-zoom

🔎🖼 A JavaScript library for zooming images like Medium
https://medium-zoom.francoischalifour.com
MIT License
3.58k stars 162 forks source link

Feature request: max-width option #74

Open edwardhorsford opened 5 years ago

edwardhorsford commented 5 years ago

I'd like to suggest adding a max-width option to limit the size of the images - particularly on wide screens.

The problem

I prefer a margin on my images. The current margin option works on medium screens, but not on large ones. I can set a 200px margin that looks good up to ~1500px or so, but when screens are larger, I don't want the image to continue to expand - I'd prefer it have a maximum size. I don't think it's possible to achieve this with margins.

At least some of medium's images appear to have some form of max width - though perhaps this is due to the native image's dimensions.

Solution

Let users specify a max-width in their options.

I suspect this is possible with a custom template - but wonder if this is general purpose enough a need that it might be provided by default.

francoischalifour commented 5 years ago

This is the first time having this feature request – I don't think it's worth having it in the library itself.

To solve this issue, you can either use a custom template or add break points to the margin option (see #69).

edwardhorsford commented 5 years ago

Thanks for the reply! I think it's possibly more noticable for me because I work on a large monitor with a wide viewport.

Unless I'm misunderstanding, having the image stay at a fixed size is not possible with margins and breakpoints without doing a breakpoint for every resolution. Otherwise the image will continue to grow in steps.

I'll take a look at the custom templates.