I am using ActionText with image upload using the image_processing
gem. However, when uploading images they do not go to S3 which is set in Active Storage.
All other image uploads work fine and go into my S3 buckets as expected. It is just images uploaded into the ActionText editor that does not use the S3 URL. They do go into the correct buckets, however. It is just the URL that I can't change or get access to in the blob
element.
I assume there is a setting in an initializer or config that I have not been able to find but I can't find it through the documentation or google.
The URL the blob is currently using is the rail/active_storage/
storage URL and I need it to use the S3 URL I have set in the active_storage.yml file.
Turns out I could edit the URL in the _blob.html.erb
file. First I had to check if I was in Production or not. Once I verify that I was able to construct the URL to grab from S3 using the blob.key
.
<% if blob.representable? %>
<% if Rails.env == 'production' %>
<img class: "post-actiontext-image" src="https://<%= ENV['S3_BUCKET'] %>.s3-<%= ENV['AWS_REGION'] %>.amazonaws.com/<%= blob.key %>" />
<% else %>
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]), class: "post-actiontext-image" %>
<% end %>
<% end %>