Class: Decidim::DecidimAwesome::ContentParsers::EditorImagesParser
- Inherits:
-
ContentParsers::BaseParser
- Object
- ContentParsers::BaseParser
- Decidim::DecidimAwesome::ContentParsers::EditorImagesParser
- Defined in:
- lib/decidim/decidim_awesome/content_parsers/editor_images_parser.rb
Overview
A parser that searches for editor images from CarrierWave in html contents and replaces them with migrated images to ActiveStorage
Instance Method Summary collapse
- #editor_images ⇒ Object
-
#rewrite ⇒ String
The content with the CarrierWave images replaced.
Instance Method Details
#editor_images ⇒ Object
19 20 21 22 23 |
# File 'lib/decidim/decidim_awesome/content_parsers/editor_images_parser.rb', line 19 def editor_images @editor_images ||= parsed_content.search(:img).index_with do |image| context[:routes_mappings].find { |mapping| image.attr(:src).end_with?(mapping[:origin_path]) } end.compact end |
#rewrite ⇒ String
Returns the content with the CarrierWave images replaced.
12 13 14 15 16 17 |
# File 'lib/decidim/decidim_awesome/content_parsers/editor_images_parser.rb', line 12 def rewrite return content if editor_images.blank? replace_editor_images parsed_content.to_html end |