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

feat: Webp images with fallback #99

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

meanmachin3
Copy link
Contributor

Not quite the solution I like, but need a feedback, if this working out in the right direction

Fix #45

</ul>
<a target="_blank" href="mailto:[email protected]">[email protected]</a>
</div>
<div class="col-md-6 text-center">
{% asset logo-small.png alt="PyCon India 2019 Logo" width="70%" %}
<picture>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very comfortable with this either.

Ideally, we should have a custom tag(say image instead of srcset) and it should be invoked like

{% image src=logo-small.png alt="PyCon India Logo" %}

and that should render

<picture>
    <source srcset="./assets/images/logo-small.png" type="image/png>
    <source srcset="./assets/images/logo-small.webp" type="image/webp">
</picture>

Like we discussed earlier, if generating webp images is the issue, we can offload it from this PR. Let's manually check-in webp equivalents with their checksum. I don't really think we are going to keep adding images from now. That way, the only thing that needs to be done is implementing this custom tag. I can help with manually generating webp images if you want.

Let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually generating webp isn't quite the problem I am facing. I've update PR, need a little help with the checksum part though

tag = "<picture>
<source srcset='./assets/images/#{@args[:src]}.webp' type='image/webp'>
<img src='./assets/images/#{@args[:src]}.png' alt='#{@args[:alt] unless @args[:alt].nil?}' #{width unless @args[:width].nil?}>
</picture>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than checking for each attribute like this, can we just loop over all attributes and add them here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astronomersiva Can you check now ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good...I believe the only issue now is with versioning the files(the checksum)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astronomersiva Yes. Do you have any suggestions wrt versioning ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try using the jekyll assets helper here? Let's try that out and see

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.

Use webp for images with fallback
2 participants