Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Aspect Ratio / Cropping on Resize #15

Closed
davegreenwp opened this issue Sep 4, 2014 · 5 comments
Closed

Aspect Ratio / Cropping on Resize #15

davegreenwp opened this issue Sep 4, 2014 · 5 comments

Comments

@davegreenwp
Copy link

Hello!

First of all, love the plugin!

The fixed height of the slider means that the image doesn't respond with the correct proportions: you end up with a totally different aspect ratio and the image is cropped.

Do you have any plans to address this?

Cheers,
Dave

@gilbitron
Copy link
Contributor

Hi Dave. What would you like to see happen?

@davegreenwp
Copy link
Author

Hullo!

I think ideally the background size of the slides needs to be 100%, with the position of the image in the top left. Also, I think it would be brilliant if the script had a couple of aspect ratio options: 4:3 or 16:9 just as an example. Maybe it defaults to 16:9, but open this up as a config option with several defined ratios.

When the page loads and the script runs, it simply checks the width of the slide container and then applies the correct height for that ratio. Alternatively, the script could just calculate the ratio from the image dimensions and apply this by default: with other options available if the user wants to override?

I've got images here that are 1280 x 549 so the ratio is 2.33 which is quite common. So at 640px width, that's going to be 275px height.

I'm half tempted to have a look at the code and maybe submit a PR. :)

Cheers,
Dave

@gilbitron
Copy link
Contributor

At the moment I've decided to go down the road of letting the user set the height of the slider. If you want to make it work with aspect ratios it would be easy to do using some custom JS (maybe use the afterChange callback?). However I don't think I'm going to include it in the core at the moment, unless there is a huge demand for it.

@DannyCooper
Copy link

Is there a way to programmatically scale the height as the width changes?

Simple example: if the starting size is 900px x 300px. By the time the width reaches 600px the height would be 200px.

I've tried using media queries but it doesn't seem possible to do it in a linear manner.

Thanks for IIS Gilbert, it's extremely useful.

@davegreenwp
Copy link
Author

A callback function that adjusts the height based on the chosen aspect ratio for the current width when the page is loaded will work. I'll probably be doing this myself over the next few days or so.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants