Skip to content

Commit

Permalink
Merge ccfaeee into 4cb5740
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlazypanda authored Sep 2, 2020
2 parents 4cb5740 + ccfaeee commit 436485a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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, <a href='/notes/edit/#{@node.id}?#{request.env['QUERY_STRING']}&legacy=true'>click here</a>."
render template: 'editor/rich'
Expand Down
6 changes: 6 additions & 0 deletions app/views/editor/rich.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
>Select an optional main image for your post.</span
>
</p>
<p>
<input class="form-control input-lg" type="text" id="alt-text" placeholder="Add alternate text for image" value="<% if @node && @node.main_image.photo_text %><%= @node.main_image.photo_text %><% else %><%= params[:photo_text] %><% end %>"/>
</p>
<p>
<input class="form-control input-lg" type="text" id="alt-text" placeholder="Add alternate text for image" value="<% if @node && @node.main_image.photo_text %><%= @node.main_image.photo_text %><% else %><%= params[:photo_text] %><% end %>"/>
</p>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/notes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% if @node.main_image %>
<a class="main-image" style="max-width:100%;width:800px;" href="<%= @node.main_image.path(:original) %>">
<%= 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%;') %>
</a>
<!--<div class="expand"><a onClick="$('.main-image').toggleClass('compressed');"><i class="fa fa-angle-down"></i></a></div>-->
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20200629163837_add_photo_text_to_images.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPhotoTextToImages < ActiveRecord::Migration[5.2]
def change
add_column :images, :photo_text, :string
end
end

0 comments on commit 436485a

Please sign in to comment.