mirror of
https://github.com/thomasjsn/hugo-theme-hello-friend.git
synced 2024-11-14 04:15:07 +01:00
Added custom alt text functionality to post cover images
This commit is contained in:
parent
ea9fa9c43d
commit
4c9276c71d
@ -201,6 +201,7 @@ Adding a cover image to your post is simple and there are two options when you e
|
|||||||
* Resulting in `https://www.yourpage.com/path/to/absolute/img.jpg`
|
* Resulting in `https://www.yourpage.com/path/to/absolute/img.jpg`
|
||||||
* Use `cover = "img.jpg"` and `useRelativeCover = true` to link the image relative to the blog post folder
|
* Use `cover = "img.jpg"` and `useRelativeCover = true` to link the image relative to the blog post folder
|
||||||
* Resulting in `https://www.yourpage.com/posts/blog-entry-xy/img.jpg`
|
* Resulting in `https://www.yourpage.com/posts/blog-entry-xy/img.jpg`
|
||||||
|
* Use `coverAlt = "description of image"` to add custom alt text to the cover image (defaults to post or page title as alt text)
|
||||||
* Use `coverCaption = "Image Credit to [Barry Bluejeans](https://unsplash.com/)"` to add a caption for the cover image.
|
* Use `coverCaption = "Image Credit to [Barry Bluejeans](https://unsplash.com/)"` to add a caption for the cover image.
|
||||||
|
|
||||||
## How to display the Last Modified Date in your posts
|
## How to display the Last Modified Date in your posts
|
||||||
|
@ -45,9 +45,9 @@
|
|||||||
{{ if .Params.Cover }}
|
{{ if .Params.Cover }}
|
||||||
<figure class="post-cover">
|
<figure class="post-cover">
|
||||||
{{ if .Params.UseRelativeCover }}
|
{{ if .Params.UseRelativeCover }}
|
||||||
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Title | plainify | default " " }}"/>
|
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Params.CoverAlt | plainify | default .Title }}"/>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Title | plainify | default " " }}"/>
|
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Params.CoverAlt | plainify | default .Title }}"/>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if .Params.CoverCaption }}
|
{{ if .Params.CoverCaption }}
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
{{ if .Params.Cover }}
|
{{ if .Params.Cover }}
|
||||||
<figure class="post-cover">
|
<figure class="post-cover">
|
||||||
{{ if .Params.UseRelativeCover }}
|
{{ if .Params.UseRelativeCover }}
|
||||||
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Title | plainify | default " " }}" />
|
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Params.CoverAlt | plainify | default .Title }}" />
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Title | plainify | default " " }}" />
|
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Params.CoverAlt | plainify | default .Title }}" />
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if .Params.CoverCaption }}
|
{{ if .Params.CoverCaption }}
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
{{ if .Params.Cover }}
|
{{ if .Params.Cover }}
|
||||||
<figure class="post-cover">
|
<figure class="post-cover">
|
||||||
{{ if .Params.UseRelativeCover }}
|
{{ if .Params.UseRelativeCover }}
|
||||||
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Title | plainify | default " " }}" />
|
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Params.CoverAlt | plainify | default .Title }}" />
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Title | plainify | default " " }}" />
|
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Params.CoverAlt | plainify | default .Title }}" />
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if .Params.CoverCaption }}
|
{{ if .Params.CoverCaption }}
|
||||||
|
Loading…
Reference in New Issue
Block a user