adobe / helix-importer-ui

Apache License 2.0
21 stars 27 forks source link

[import] Extra downloaded resources do not have a preview #328

Open kptdobe opened 7 months ago

kptdobe commented 7 months ago

You can use the following import.js to download all page images:

export default {
  transform: ({ document, url }) => {
    const result = [];
    const images = document.querySelectorAll('img');
    images.forEach((img) => {
      const u = new URL(img.src, url);
      const newPath = WebImporter.FileUtils.sanitizePath(u.pathname);
      const imgData = {
        path: newPath,
        from: img.src,
      };
      result.push(imgData);
    });

    return result;
  },
};

You can also follow instructions from https://github.com/adobe/helix-importer-ui/blob/main/docs/download-pdf.md to download the pdf. In both cases, no preview is available for those assets. For images, it would be great to preview the images in the Preview panel (and hide other tabs) and for PDF have a download link or something...

This is a nice to have, using the Save file locally option gives the asset.