Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carousel / Saved Templates: Poster generation not working #12513

Closed
swissspidy opened this issue Oct 19, 2022 · 2 comments
Closed

Carousel / Saved Templates: Poster generation not working #12513

swissspidy opened this issue Oct 19, 2022 · 2 comments
Assignees
Labels
Group: Media Group: Page Templates Group: WordPress Changes related to WordPress or Gutenberg integration P1 High priority, must do soon Type: Bug Something isn't working

Comments

@swissspidy
Copy link
Collaborator

Bug Description

While looking at #12512 I noticed that the poster images for saved templates are no longer generated/uploaded.

Expected Behaviour

When saving a page as template, we ought to take a poster image and upload that to WP. But this doesn't seem to be happening anymore.

Code in question:

const imageUrl = page.image?.url || pageDataUrl;
const shouldPostBlob =
hasUploadMediaAction && pageDataUrl && !page.image?.url;
useEffect(() => {
if (!shouldPostBlob) {
return;
}
(async () => {
try {
const blob = await fetchRemoteBlob(pageDataUrl);
const file = blobToFile(
blob,
`web-stories-page-template-${page.templateId}.jpg`,
'image/jpeg'
);
const resource = await uploadFile(file, {
templateId: page.templateId,
mediaSource: 'page-template',
});
updatePageTemplate(page.templateId, {
featured_media: resource.id,
});
updateSavedTemplate({
templateId: page.templateId,
image: {
id: resource.id,
height: resource.height,
width: resource.width,
url: resource.src,
},
});
} catch (err) {
// Catch upload errors, e.g. if the file is too large,
// so that the page template can still be added, albeit without an image.
trackError('upload_generated_page_template_image', err?.message);
}
})();
}, [
pageDataUrl,
uploadFile,
updatePageTemplate,
page.templateId,
shouldPostBlob,
updateSavedTemplate,
]);

Steps to Reproduce

  1. Save current page as template
  2. Notice lack of network requests to upload poster image
  3. Check DOM to see that no image has been uploaded

Screenshots

Screenshot 2022-10-19 at 21 21 59

Additional Context

  • Plugin Version: 1.25
  • WordPress Version:
  • Operating System:
  • Browser:
@swissspidy swissspidy added Type: Bug Something isn't working Group: Media P2 Should do soon Group: WordPress Changes related to WordPress or Gutenberg integration Pod: WP Group: Page Templates P1 High priority, must do soon and removed P2 Should do soon Pod: WP labels Oct 19, 2022
@swissspidy
Copy link
Collaborator Author

This seems to hang somewhere in storyPageToDataUrl, with the htmlToImage.toJpeg call seemingly never resolving.

I noticed that this issue not only affects saved templates, but also the carousel in the workspace. No images are ever created.

Screenshot 2022-10-24 at 14 50 13

@swissspidy swissspidy changed the title Saved Templates: poster images not being uploaded Carousel / Saved Templates: Poster generation not working Oct 24, 2022
@merapi
Copy link
Contributor

merapi commented Nov 9, 2022

Fix is already on main, tested on local env and staging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Media Group: Page Templates Group: WordPress Changes related to WordPress or Gutenberg integration P1 High priority, must do soon Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants