Skip to content

Introducing images!

Posted by author in the category "blog"

Heads up! This article is quite old. Take a look at the official documentation for the latest information.

The v0.10.0 release introduces featured images for blog posts.

Add images to your posts by setting the image in the front matter. If you pass a string it will be used to find an image in the _media directory if the file is local. If you supply a full URL starting with https:// it will be used as-is.

Adding basic images

Add a Local image

image: image.jpg # Will load the following `_site/_media/image.jpg`

Add a Remote image

image: # Will load the URL directly

Using the full power of the Image object to create rich and accessible images

If you want to be fancy you can supply extra data to the image. To do this you instead pass an array as the image parameter.

source: image.jpg
description: Alt text
title: Tooltip

Supported properties:

Here are the properties supported by the Image object, paired with examples and descriptions.

Local image path

path: _media/image.jpg

Remote image URL

Will override the path property if both are set.


Alt description

Used for alt text for screen readers. You should always set this to provide accessibility.

description: "This is an image of a cat sitting in a basket."

Image title

Shows a tooltip on hover.

title: "My Cat Archer"

Copyright text

copyright: "Copyright (c) 2020 John Doe"

License name.

license: "CC BY-NC-SA 4.0"

License URL.

licenseUrl: ""

Image author

The author of the image, for example, the photographer, illustrator, stock photo website, etc.

author: "John Doe"

Image source

Used together with the author property to give credit to the source of the image.

credit: "htps://"

Practical example

Using all of the supported properties described above, we can create an image that is accessible and data-rich.

The source markdown

title: A cute kitten I found on Pixabay
description: I found this cute kitten, and thought it would make a great example for featured images in posts!
category: example
author: Caen
date: 2022-04-11 15:51
description: "Image of a small kitten with its head tilted, sitting in a basket weaved from nature material."
title: "Kitten Gray Kitty [sic]"
copyright: Copyright (c) 2022
license: Pixabay License
author: Godsgirl_madi
## Write something awesome.

Parsed HTML output

<figure role="doc-cover" itemprop="image" itemscope="" itemtype="">
<img src="" alt="Image of a small kitten with its head tilted, sitting in a basket weaved from nature material." title="Kitten Gray Kitty [sic]" itemprop="image" class="mb-0">
<figcaption itemprop="caption">
Image by <span itemprop="creator" itemscope="" itemtype=""><a href="" rel="author noopener" itemprop="url"><span itemprop="name">Godsgirl_madi</span></a></span>. <span itemprop="copyrightNotice">Copyright (c) 2022</span>. License by <a href="" rel="license nofollow noopener" itemprop="license">Pixabay License</a>
<meta itemprop="text" content="Image of a small kitten with its head tilted, sitting in a basket weaved from nature material.">
<meta itemprop="name" content="Kitten Gray Kitty [sic]">

Screenshot of the output

Deep dive into the Image object

If you are a package developer, or just curious, here is an overview of how the Image object is created internally.

An Image object is created by passing an array of values to the constructor.

Here is an example, with all the supported properties, and example values.

public static function exampleImage(): self
return new Hyde\Framework\Models\Image([
'path' => '_media/image.jpg',
'url' => '',
'description' => 'A random image.',
'title' => 'An image from Picsum',
'copyright' => 'Copyright (c) 2022',
'license' => 'CC BY-NC-SA 4.0',
'licenseUrl' => '',
'credit' => '',
'author' => 'John Doe',

Syntax highlighting by

End of article