Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set size/rotate image in jekyll?

How to set size of image in jekyll markdown?

![steam-fish-1]({{ "/assets/steam-fish-1.jpeg" | absolute_url }})

I'm using jekyll minima. Using

![steam-fish-1]({{ "/assets/steam-fish-1.jpeg" | absolute_url }} =250x)

from Changing image size in Markdown doesn't work. If possible, I would like to know how to rotate image as well.

like image 590
ZHU Avatar asked Jan 01 '19 00:01

ZHU


People also ask

Can you resize an image in Markdown?

Overview. There are a lot of Markdown flavors, but the most popular one is the Github Flavor Markdown (GFM). Unfortunately, there is no support for resizing an image using the Markdown syntax. Raw HTML needs to be used to change the image size in Markdown.

How do I style an image in Markdown?

This post presents a variety of ways to format images with Markdown, from brute force to proprietary syntax extensions, unwise hacks, and everything in between. That is, Markdown allows you to specify an <img> tag with src , alt , and title attributes in HTML.

How do I rotate an image tag in CSS?

Once the CSS code is applied to your . css file, stylesheet, or <style> tags, you can use the CSS class name in any of your image tags. To rotate an image by another measure of degrees, change the "180" in the CSS code and <img> tag to the degree you desire.


2 Answers

Jekyll seems to accept attribute lists. You can set the size of an image as follows:

![steam-fish-1](/assets/steam-fish-1.jpeg){: width="250" }

(or use height="250"). The property value is in pixels, and should (according to the HTML spec) not have explicit units.

like image 58
Cris Luengo Avatar answered Sep 19 '22 20:09

Cris Luengo


Markdown doesn't have built in support for image-sizes, so the only real solution is to use a little HTML inside your markdown. Given that, my jekyll-image-size plugin can do the resizing you need without any CSS.

Example:

<!-- template -->
{{ /assets/steam-fish-1.jpeg:img?width=250 alt='steam-fish-1' }}

<!-- output -->
<a href="/assets/steam-fish-1.jpeg" width='250' height='YYY' alt='steam-fish-1'>

(Where YYY is the actual, proportionally scaled height of your image.)

If you need the absolute_url filter:

<!-- template -->
<a 
  href={{ "/assets/steam-fish-1.jpeg" | absolute_url }} 
  {{ /assets/steam-fish-1.jpeg:props?width=250 }} 
  alt='steam-fish-1'
>

<!-- output -->
<a href="http://test.com/assets/steam-fish-1.jpeg" width='250' height='YYY' alt='steam-fish-1'>

For rotating your images, would it make sense to just rotate the image file itself?

like image 44
Shane Brinkman-Davis Avatar answered Sep 22 '22 20:09

Shane Brinkman-Davis