Sha256: 1ed2a484b14b52538b3eac966963fd5dc60213b0d68c25a7cb1b85e287960240
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require_relative 'post' module Contentful module Exporter module Wordpress class PostAttachment < Post attr_reader :post, :settings def initialize(post, settings) @post = post @settings = settings end def attachment_extractor create_directory("#{settings.assets_dir}/attachment_post") asset = { id: attachment_id, description: attachment_description, url: attachment_url } unless asset[:url].nil? write_json_to_file("#{settings.assets_dir}/attachment_post/#{attachment_id}.json", asset) asset end end private def attachment_url post.at_xpath('wp:attachment_url').text unless post.at_xpath('wp:attachment_url').nil? end def attachment_id "attachment_#{post_id(post)}" end def attachment_description alt = post.xpath('.//wp:meta_key[contains(text(), "_wp_attachment_image_alt")]').first alt ? alt.parent.at_xpath('wp:meta_value').text : '' end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wordpress-exporter-0.2.0 | lib/wordpress/post_attachment.rb |
wordpress-exporter-0.1.0 | lib/wordpress/post_attachment.rb |
wordpress-exporter-0.0.2 | lib/wordpress/post_attachment.rb |