Skip to content

Commit

Permalink
feat: add hyperlink image shortcode (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-baiborodine authored Oct 21, 2023
1 parent 65a159c commit 38fb69b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
32 changes: 22 additions & 10 deletions v4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ markdown, you can use the `series` shortcode with the series name in question, f
{{< series "My New Super Series" >}}
```

### External Images
### Images

#### External Images

If you would like to use external images, such as those stored on another server or in the cloud, as
a featured image for your article or in the `gallery` post type, you can use them by setting the
Expand All @@ -499,14 +501,14 @@ gallery: [
]
```

### Image Modal Zoom
#### Image Modal Zoom

When you include an image larger than the content area, the image becomes interactive, and a larger version can be
opened in a lightbox. Modal zoom will work only for images that are added using the standard markdown
annotation, e.g., `![Image alt text](/my_image.png)` or `![Image alt text](/my_image.png "Image figure caption")` for
images with a figure caption. Please note that this feature will not work for images added using raw HTML.

### Featured Image
#### Featured Image

There are two options for adding a featured image to a post. The first approach is to use a [single-page](#single-page)
post with the `featuredImage` front matter variable, where the value for this variable should be either the path
Expand All @@ -524,16 +526,26 @@ content
      └── index.md
```

### Automatic Image Resizing
#### Automatic Image Resizing

Bilberry theme includes built-in automatic cropping and resizing only for **featured** and **gallery**
images, activated by default. However, if you want to disable it, set the `resizeImages`
parameter to `false` in the `config.toml` file. Also, this feature can be disabled at the post level
by setting the `resizeImages` front matter variable to `false`.

For a featured image to be cropped and resized, it should be named `featuredImage.*` and placed
within the page bundle's folder.

Bilberry theme includes built-in automatic cropping and resizing only for **featured** and **gallery** images, activated
by default. However, if you want to disable it, set the `resizeImages` parameter to `false` in the `config.toml` file.
Also, this feature can be disabled at the post level by setting the `resizeImages` front matter variable to `false`.
**NOTE**: a featured image defined via the `featuredImage` front matter parameter will **NOT** be
cropped and resized.

For a featured image to be cropped and resized, it should be named `featuredImage.*` and placed within the page bundle
folder.
#### Hyperlink Image

**NOTE**: a featured image defined via the `featuredImage` front matter parameter will **NOT** be cropped and resized.
If you want to display an image as a hyperlink, use the `hyperlink-image` shortcode as follows:

```markdown
{{< hyperlink-image "<image-text>" "<image-url>" "<link-url>" >}}
```

### Video

Expand Down
9 changes: 9 additions & 0 deletions v4/layouts/shortcodes/hyperlink-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ $imageText := .Get 0 }}
{{ $imageUrl := .Get 1 }}
{{ $linkUrl := .Get 2 }}

<p>
<a href="{{ $linkUrl }}">
<img src="{{ $imageUrl }}" alt="{{ $imageText }}">
</a>
</p>

0 comments on commit 38fb69b

Please sign in to comment.