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

Slug-based widths are not sorted correctly #17

Open
sjwilliams opened this issue Dec 29, 2015 · 1 comment
Open

Slug-based widths are not sorted correctly #17

sjwilliams opened this issue Dec 29, 2015 · 1 comment
Assignees
Labels

Comments

@sjwilliams
Copy link
Owner

If laziestloader is given slug-based widths, it incorrectly assumes that they're presorted from smallest to largest. So an example like this will fail to pick the correct rendition:

<img data-pattern="https://graphics8.nytimes.com/images/53rd-place-nytimestravel-1-{{size}}.jpg" data-widths="[{"size":320,"slug":"square320"},{"size":75,"slug":"thumbStandard"},{"size":151,"slug":"moth"},{"size":190,"slug":"filmstrip"},{"size":190,"slug":"articleInline"},{"size":600,"slug":"articleLarge"},{"size":163,"slug":"hpSmall"},{"size":50,"slug":"blogSmallThumb"},{"size":151,"slug":"blogSmallInline"},{"size":480,"slug":"blog480"},{"size":533,"slug":"blog533"},{"size":427,"slug":"blog427"},{"size":362,"slug":"tmagSF"},{"size":592,"slug":"tmagArticle"},{"size":500,"slug":"slide"},{"size":750,"slug":"jumbo"},{"size":750,"slug":"superJumbo"},{"size":640,"slug":"square640"},{"size":150,"slug":"thumbLarge"},{"size":225,"slug":"blog225"},{"size":177,"slug":"mediumFlexible177"},{"size":675,"slug":"master675"},{"size":495,"slug":"master495"},{"size":180,"slug":"master180"},{"size":149,"slug":"mediumSquare149"},{"size":315,"slug":"master315"},{"size":168,"slug":"smallSquare168"},{"size":252,"slug":"smallSquare252"}]" src="https://cms-service.stg.nytimes.com/data/cms/files/2015/12/27/100000004055844/53rd-place-nytimestravel-1-smallSquare252.jpg">

On quick inspection of the source, the internal bestFit() method does sort smallest to largest. The issue is likely here, where the slug/object-specific logic relates the best fit selection back to the original hash.

@sjwilliams sjwilliams added the bug label Dec 29, 2015
@sjwilliams sjwilliams self-assigned this Dec 29, 2015
@sjwilliams sjwilliams changed the title Slug-based widths are not sorted Slug-based widths are not sorted correctly Dec 29, 2015
@sjwilliams
Copy link
Owner Author

And double check int-based widths, too. @wmandrews reported that [720,320] failed but [320, 720] worked for him. Seems like this should be sorted on line 186...

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

No branches or pull requests

1 participant