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

Easier image insertion in posts #560

Closed
fa-ribeiro opened this issue Sep 28, 2016 · 1 comment
Closed

Easier image insertion in posts #560

fa-ribeiro opened this issue Sep 28, 2016 · 1 comment
Milestone

Comments

@fa-ribeiro
Copy link
Contributor

fa-ribeiro commented Sep 28, 2016

Based on eduardo bouças blog post, I created an image tag to simplify image insertion on posts (with and without captions). It presumes all images are placed under asset/images and all I have to do is to specify image path from that point. The syntax is something like this:

{% include image name="2016/07/MyPostImage.png" caption="The optional image caption" %}

The include file image looks like this:

{% if include.caption %}
  <figure>
    <img src="{{ site.url }}{{ site.baseurl }}/assets/images/{{ include.name }}" {% if include.alt %} alt="{{ include.alt }}" {% endif %} {% if include.width %} width="{{ include.width }}" {% endif %}/>
    <figcaption>{{ include.caption }}</figcaption>
  </figure>
{% else %}
  <img src="{{ site.url }}{{ site.baseurl }}/assets/images/{{ include.name }}" {% if include.alt %} alt="{{ include.alt }}" {% endif %} {% if include.width %} width="{{ include.width }}" {% endif %}/>
{% endif %}

I'me wondering if it would be interesting to add this feature to the theme. if yes, I can submit a PR.

What do you think?

@mmistakes
Copy link
Owner

Could be a nice compliment to the gallery helper. If you want to work on a PR that would be cool. I'd suggest trying to use some of the same variable names to keep things consistent.

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

No branches or pull requests

2 participants