Skip to content

Instantly share code, notes, and snippets.

@Biaggio74
Last active June 15, 2020 07:56
Show Gist options
  • Save Biaggio74/a7a649e29cd3a77e429293011ae1cb30 to your computer and use it in GitHub Desktop.
Save Biaggio74/a7a649e29cd3a77e429293011ae1cb30 to your computer and use it in GitHub Desktop.
Ghost blog: image quick resizing with markdown and pick up ALT for caption

Resizing Ghost blog image with MD and pick up the ALT of the image

These few lines gives a quick control on the image size in case you don't want a full width or full screen image. You create the MD image as below to resize the image by 50% for instance:

![This is the ALT and caption of an image. @50%](https://blog.yourdomain.com/storage/image.png)

This will create the below img tag in HTML. The @50% will be truncated from the caption, but it will be still present in the ALT. You can use whatever size after the @ between 1 and 100. Then the integer has to be followed by %.

<figure class="image">
  <img src="https://blog.yourdomain.com/storage/image.png" 
       alt="This is the ALT and caption of an image.@50%" 
       style="width: 55%; display: block; margin: auto;">
  <figcaption>This is the ALT and caption of an image.</figcaption>
</figure>

Just paste the code snippet to your Ghost Blog admin Code injection's Site Footer and you are good to go. The base caption function made by Kevin Chung here.

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