最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Upload webp images from wordpress api - Wordpress - Stack Overflow

matteradmin7PV0评论

Using node. I want to upload some images to wordpress using the wordpress api. I tested and it works with png. Is this not possible with webp or maybe my code is wrong? I tried before with the UI and it works with webp.

This is the function

export async function testAddingMedia(league, teamAbbr1, teamAbbr2) {


  /* 
  IMPORTANT PART OF generateFeaturedMedia
  return await background
      posite([
        { "input": team0LogoPath, "top": Math.round((metaBackground.height / 2) - (353)), "left": Math.round((metaBackground.width / 2) - 780) },
        {
          "input": team1LogoPath, "top":   Math.round((metaBackground.height / 2) - 
        (353)), "left":  Math.round((metaBackground.width / 2) + 195),
        },
      ])
      .webp()
      .toBuffer(); */
  const imageBuffer = await generateFeaturedMedia(
    teamAbbr1, // this is used to find some images and join in a new img
    teamAbbr2,
    league
  );
  
  const filename = "someName"
  const response = await fetch(apiMediaUrl, {
    "method":  'POST',
    "headers": {
      'Content-Disposition': `attachment; filename="${filename}"`,
      'Authorization':       `Basic ${token}`, // this is defined outside
      'Content-Type':        'image/webp',
    },
    "body": imageBuffer,
  });
  console.log("
Post a comment

comment list (0)

  1. No comments so far