【问题标题】:Src of an image with text + php variable带有文本 + php 变量的图像的 Src
【发布时间】:2021-09-17 15:39:12
【问题描述】:

嘿,我很难让它工作我用这个code

将图片上传为base64,然后显示订单详情 一切正常,图片已上传,但我无法显示上传的图片

这是函数

/**
 * Add order item meta.
 */

add_action( 'woocommerce_add_order_item_meta', 'add_order_item_meta' , 10, 2);

function add_order_item_meta ( $item_id, $values ) {

    if ( isset( $values [ 'custom_data' ] ) ) {

      save_image($custom_data);
      $image =  " <img src='https://mywebsite.com/wp-content/uploads/2021/07/ .$hashed_filename' >";

      wc_add_order_item_meta( $item_id, 'Image', $image );
        
    }
}

经过测试图片只显示链接没有变量

正如我在 google 上看到的,我需要在变量之前添加 echo,但我不能,因为它将保存在该函数的变量中 ($image)

【问题讨论】:

  • hashed_filename 代表什么?
  • $hashed_filename 之前有一个dot .,我猜这没用。删除它,因为它没有任何用途。
  • 在函数中,您在哪里获得 $hashed_filename 的值,因为我看不到任何来源?
  • $hashed_filename 在函数中为空(没有任何值)
  • 我看到了,但是你从哪里传递函数中的值?它是空的。

标签: php image woocommerce base64 base64url


【解决方案1】:

你可以试试这个

$image =  "<img src='https://mywebsite.com/wp-content/uploads/2021/07/" . $hashed_filename . "'>";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-29
    • 2018-07-01
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 2015-03-06
    • 2015-04-27
    • 1970-01-01
    相关资源
    最近更新 更多