From a9d5d68e810bc07fad6670cacd126b7f712d647c Mon Sep 17 00:00:00 2001 From: Tlazypanda <33183263+Tlazypanda@users.noreply.github.com> Date: Tue, 30 Jun 2020 15:52:32 +0530 Subject: [PATCH 1/2] Add alternate text for images --- app/controllers/notes_controller.rb | 6 ++++++ app/views/editor/rich.html.erb | 3 +++ app/views/notes/show.html.erb | 2 +- db/migrate/20200629163837_add_photo_text_to_images.rb | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200629163837_add_photo_text_to_images.rb diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 178e4a4811..ab2d751cdb 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -167,10 +167,16 @@ def edit else if @node.main_image @main_image = @node.main_image.path(:default) + @node.main_image.photo_text = params[:photo_text] + @node.save! elsif params[:main_image] && Image.find_by(id: params[:main_image]) @main_image = Image.find_by(id: params[:main_image]).path + Image.find_by(id: params[:main_image]).photo_text = params[:photo_text] + Image.find_by(id: params[:main_image]).save! elsif @image @main_image = @image.path(:default) + @image.photo_text = params[:photo_text] + @image.save! end flash.now[:notice] = "This is the new rich editor. For the legacy editor, click here." render template: 'editor/rich' diff --git a/app/views/editor/rich.html.erb b/app/views/editor/rich.html.erb index 08141feade..d2e823a8a6 100644 --- a/app/views/editor/rich.html.erb +++ b/app/views/editor/rich.html.erb @@ -112,6 +112,9 @@ >Select an optional main image for your post.

+

+ +

diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb index 6de2d84cc3..7ca038c2c1 100644 --- a/app/views/notes/show.html.erb +++ b/app/views/notes/show.html.erb @@ -14,7 +14,7 @@ <% if @node.main_image %> - <%= image_tag(@node.main_image.path(:large), class:"rounded d-none d-lg-inline", style:'max-height:600px;max-width:100%;') %> + <%= image_tag(@node.main_image.path(:large), class:"rounded d-none d-lg-inline", style:'max-height:600px;max-width:100%;', alt:@node.main_image.photo_text) %> <%= image_tag(@node.main_image.path(:large), class:"rounded d-lg-none", style:'width:100%;') %> diff --git a/db/migrate/20200629163837_add_photo_text_to_images.rb b/db/migrate/20200629163837_add_photo_text_to_images.rb new file mode 100644 index 0000000000..da7ab4c922 --- /dev/null +++ b/db/migrate/20200629163837_add_photo_text_to_images.rb @@ -0,0 +1,5 @@ +class AddPhotoTextToImages < ActiveRecord::Migration[5.2] + def change + add_column :images, :photo_text, :string + end +end From ccfaeeea2a07a320bf877b094732c2d41f97267b Mon Sep 17 00:00:00 2001 From: Tlazypanda <33183263+Tlazypanda@users.noreply.github.com> Date: Tue, 30 Jun 2020 15:52:32 +0530 Subject: [PATCH 2/2] Add alternate text for images --- app/views/editor/rich.html.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/editor/rich.html.erb b/app/views/editor/rich.html.erb index d2e823a8a6..d711af79bf 100644 --- a/app/views/editor/rich.html.erb +++ b/app/views/editor/rich.html.erb @@ -115,6 +115,9 @@

+

+ +