Skip to content

Instantly share code, notes, and snippets.

@corporealfunk
Last active March 11, 2021 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corporealfunk/599fa99c52750508f997dec6e7be2f25 to your computer and use it in GitHub Desktop.
Save corporealfunk/599fa99c52750508f997dec6e7be2f25 to your computer and use it in GitHub Desktop.
Force SpinaCMS admin panel to not inject the host:port into the urls
# SpinaCMS will inject image URLs into the Trix content with the host:port as part of the URL
# This makes it hard to port that DB content to another host (say move from localhost to a production or staging site)
# load this patch from the config/application.rb like so:https://guides.rubyonrails.org/engines.html#overriding-models-and-controllers
Spina::ImagesHelper.class_eval do
def embedded_image_url(image)
return "" if image.nil?
main_app.polymorphic_path(image.variant(resize: Spina.config.embedded_image_size), only_path: true)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment