From 5a0279f9943fb53080832bbef538fe26e94822da Mon Sep 17 00:00:00 2001 From: Konnor Rogers Date: Tue, 28 Jan 2025 22:13:55 -0500 Subject: [PATCH] finish docs --- .../how_tos/17-adding-alt-text-to-images.md | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/src/_documentation/how_tos/17-adding-alt-text-to-images.md b/docs/src/_documentation/how_tos/17-adding-alt-text-to-images.md index 38b42351..9913b9a7 100644 --- a/docs/src/_documentation/how_tos/17-adding-alt-text-to-images.md +++ b/docs/src/_documentation/how_tos/17-adding-alt-text-to-images.md @@ -3,15 +3,17 @@ title: Adding alt text to images permalink: /how-tos/adding-alt-text-to-images/ --- -Adding alt text to "previewable attachments" is quite a challenge. Rhino Editor comes with support built in. It requires patching ActionText, so it is not part of the default experience. +Adding alt text to "previewable attachments" is quite a challenge. Rhino Editor comes with support built in, but it requires patching ActionText, so it is not part of the default experience. To start, lets configure ActionText to allow us to add the `"alt"` attribute to attachments. <%= render Alert.new(type: :warning) do %> - I have tried using attributes names such as "alt-text", "altText", and "alt_text" but ActionText / ActiveStorage seems to sanitize it away. + I have tried using other attribute names such as "alt-text", "altText", and "alt_text" but ActionText / ActiveStorage seem to sanitize it away. + + <% end %> -To do configure we can create a file at `config/initializers/actiontext_patch.rb` and add the following contents: +To configure ActionText, we can create a file at `config/initializers/actiontext_patch.rb` and add the following content: ```rb # config/initializers/actiontext_patch.rb @@ -23,30 +25,30 @@ attributes = ActionText::Attachment::ATTRIBUTES + ["alt"] ActionText::Attachment.const_set("ATTRIBUTES", attributes) ``` -If this looks funky to you, thats because it is. I filed an issue with Rails about proper `mattr_accessor` support like other Rails modules. +If this looks funky to you, thats because it is. I filed an issue with Rails about proper `mattr_accessor` support like other Rails modules to make this API nicer to work with. -Moving on. Now that ActionText can accept the "alt" attribute, we have to configure our frontend to enable the experimental alt text editor. +Moving on, now that ActionText can accept the "alt" attribute, we have to configure Rhino Editor to enable the experimental alt text editor. ## Enabling alt text editor -To do so we can do the following: +To enable the alt text editor, we can do the following: <%- code = capture do -%> <%- end.html_safe -%> -## Alt text editor example - -Add an attachment below to test out the attachment editor. - +## Alt text editor example + +Add an attachment below to test out the attachment editor. + <%= code %> ## Add the alt attribute to your attachments