Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow ratio handling by element #213

Merged
merged 2 commits into from
Jan 13, 2016

Conversation

LRancez
Copy link
Contributor

@LRancez LRancez commented Jan 12, 2016

Handling the ratio allows you to add the {height} replacement in the images url.
Also, this is specially useful when some smart cropping service is available (like https://github.com/thumbor/thumbor).

  • If the data-ratio is not set, this replace the {height} by empty (This maintains the current behavior).
  • If the data-ratio is set to a number, the {height} is replace by the proportional height according to the ratio specified.
  • if the data-ratio is set to the word "container", the ratio is automatically calculated based on the container size and the {height} is replaced accordingly.

FYI: the bgset plugin clones the attributes, so I added de data-ratio to be cloned also.

@sbehrends
Copy link

This looks to be specially useful when using bgset.

@LRancez
Copy link
Contributor Author

LRancez commented Jan 13, 2016

Hi @sbehrends and @aFarkas , thanks for the comments.
I'd uploaded the changes.
Best,

aFarkas pushed a commit that referenced this pull request Jan 13, 2016
@aFarkas aFarkas merged commit 65e2ac4 into aFarkas:master Jan 13, 2016
@aFarkas
Copy link
Owner

aFarkas commented Jan 13, 2016

thx

@jinty
Copy link
Contributor

jinty commented Feb 18, 2016

We have a similar need and have a patch which pulls out the aspect ratio from the CSS using CSS Custom Variables:

    var elemStyles = window.getComputedStyle(elem);
    var aspectRatio = elemStyles.getPropertyValue('--aspect-ratio') || '';

Would a pull request in that direction be appreciated?

http://caniuse.com/#feat=css-variables

@aFarkas
Copy link
Owner

aFarkas commented Feb 19, 2016

@aFarkas
Copy link
Owner

aFarkas commented Feb 27, 2016

@jinty
Still interested to do the PR? If yes, I would take it.

@jinty
Copy link
Contributor

jinty commented Mar 1, 2016

On Fri, Feb 26, 2016 at 11:46:34PM -0800, Alexander Farkas wrote:

@jinty
Still interested to do the PR? If yes, I would take it.

Just trying to get over a nasty flu first...

Brian Sutherland

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

Successfully merging this pull request may close these issues.

4 participants