From 7c82c9aee0e15ec1d45481d9cc772674c9a20da7 Mon Sep 17 00:00:00 2001
From: Dante Catalfamo
Date: Wed, 24 Jun 2020 22:33:33 -0400
Subject: Add hugo-org-set-image-title post
---
.../posts/hugo-org-set-image-title/dummy-image.png | Bin 0 -> 841 bytes
content/posts/hugo-org-set-image-title/index.org | 92 +++++++++++++++++++++
2 files changed, 92 insertions(+)
create mode 100644 content/posts/hugo-org-set-image-title/dummy-image.png
create mode 100644 content/posts/hugo-org-set-image-title/index.org
(limited to 'content/posts')
diff --git a/content/posts/hugo-org-set-image-title/dummy-image.png b/content/posts/hugo-org-set-image-title/dummy-image.png
new file mode 100644
index 0000000..f5ef1b1
Binary files /dev/null and b/content/posts/hugo-org-set-image-title/dummy-image.png differ
diff --git a/content/posts/hugo-org-set-image-title/index.org b/content/posts/hugo-org-set-image-title/index.org
new file mode 100644
index 0000000..ca2e663
--- /dev/null
+++ b/content/posts/hugo-org-set-image-title/index.org
@@ -0,0 +1,92 @@
+#+TITLE: How To Set An Image Title In Hugo Using Org-Mode Markup
+#+DATE: 2020-06-24T19:50:03-04:00
+#+DRAFT: true
+#+DESCRIPTION: How to set the title or alt text of an image in hugo using org-mode markup
+#+TAGS[]: hugo org-mode
+#+KEYWORDS[]: hugo org-mode
+#+SLUG:
+#+SUMMARY:
+
+One of the differences between using markdown and org-mode markup for
+writing Hugo pages is how you set the alternative text and title of an
+image.
+
+In markdown, you would write it as
+#+BEGIN_SRC
+
+#+END_SRC
+
+Where in org-mode, typically you would use a caption like this
+
+#+BEGIN_SRC org
+#+CAPTION: Image Title
+[[file:dummy-image.png]]
+#+END_SRC
+
+and that would be the end of it. However in Hugo, if we use that
+format, we end up with this
+
+#+CAPTION: Image Title
+[[file:dummy-image.png]]
+
+with the following HTML
+
+#+BEGIN_SRC html
+
+
+
+ Image Title
+
+
+#+END_SRC
+
+With the caption being put into a figure, and the image's alt text and
+title being set to the URL of the image, which isn't very helpful
+for people using screen readers, or if the image fails to load. It
+also takes up room with text we normally wouldn't be showing unless
+the image was being hovered over.
+
+If we give the org-mode link a title, it just turns into a regular
+link to an image instead of embedding it
+
+#+BEGIN_SRC org
+[[file:dummy-image.png][Image Title]]
+#+END_SRC
+
+[[file:dummy-image.png][Image Title]]
+
+resulting in this HTML
+
+#+BEGIN_SRC html
+Image Title
+#+END_SRC
+
+
+The way around this is to use the ~#+ATTR_HTML~ element in
+org-mode. You use it in the format of ~#+ATTR_HTML: :
+~. So to add a title and alt text to an image, you would add
+
+#+BEGIN_SRC org
+#+ATTR_HTML: :alt alt text
+#+ATTR_HTML: :title Image Title
+#+END_SRC
+
+Above the embedded image, resulting in
+
+#+BEGIN_SRC org
+#+ATTR_HTML: :alt alt text
+#+ATTR_HTML: :title Image Title
+[[file:dummy-image.png]]
+#+END_SRC
+
+Which finally outputs what we want
+
+#+ATTR_HTML: :alt alt text
+#+ATTR_HTML: :title Image Title
+[[file:dummy-image.png]]
+
+giving us this HTML
+
+#+BEGIN_SRC html
+
+#+END_SRC
--
cgit v1.2.3