最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Upload webp images from wordpress api - Wordpress - Stack Overflow

programmeradmin3浏览0评论

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("
发布评论

评论列表(0)

  1. 暂无评论