Skip to content

Commit

Permalink
Changed WordPress attachment format a bit to allow more data to be ad…
Browse files Browse the repository at this point in the history
…ded easily.
  • Loading branch information
felixfontein committed Jul 12, 2015
1 parent b6d8c0e commit 99f990d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nikola/plugins/command/import_wordpress.py
Expand Up @@ -453,11 +453,13 @@ def import_attachment(self, item, wordpress_namespace):
links[link] = '/' + dst_url
links[url] = '/' + dst_url

return [path] + self.download_additional_image_sizes(
result = {}
result['files'] = [path] + self.download_additional_image_sizes(
item,
wordpress_namespace,
os.path.dirname(url)
)
return result

def download_additional_image_sizes(self, item, wordpress_namespace, source_path):
if phpserialize is None:
Expand Down Expand Up @@ -835,12 +837,12 @@ def process_item_if_attachment(self, item):
wordpress_namespace, post_type, post_id, parent_id = self._extract_item_info(item)

if post_type == 'attachment':
files = self.import_attachment(item, wordpress_namespace)
data = self.import_attachment(item, wordpress_namespace)
# If parent was found, store relation with imported files
if parent_id is not None and int(parent_id) != 0:
self.attachments[int(parent_id)][post_id] = files
self.attachments[int(parent_id)][post_id] = data
else:
LOGGER.warn("Attachment #{0} ({1}) has no parent!".format(post_id, files))
LOGGER.warn("Attachment #{0} ({1}) has no parent!".format(post_id, data['files']))

def write_attachments_info(self, path, attachments):
with io.open(path, "wb") as file:
Expand Down

0 comments on commit 99f990d

Please sign in to comment.