【问题标题】:PinIt Pinterest Button Does not Show ImagePinIt Pinterest 按钮不显示图像
【发布时间】:2023-03-12 17:13:01
【问题描述】:

我在 http://www.harmonics.co.uk 有一家 Magento 商店,并且我在产品上有 PinIt 按钮。

问题是当你点击它时,它不会从查询字符串中的媒体属性中提取图像,即使 URL 是正确的。

我正在使用以下代码在产品页面上生成我的图片和 PinIt 按钮:

<?php
    $_helper = $this->helper('catalog/output');
    $_product = $this->getProduct();
    $image = $this->helper('catalog/image')->init($_product, $_product->getImageUrl(), 'image')->resize(150, 150);
?>

// PinIt Anchor
<a class="pinterest" href="http://pinterest.com/pin/create/button/?url=<?php echo $_product->getProductUrl(); ?>&amp;media=<?php echo $image; ?>&amp;description=<?php echo $_product->getName(); ?>" title="Share on Pinterest">&nbsp;</a>

它曾经可以工作,但我认为 Pinterest 已经改变了他们按钮的工作方式,但我看不出如何。生成的代码看起来几乎相同,除了生成的 URL 将 : 替换为 %3A 和 / 替换为 %2F。

我尝试过进行字符串替换,但这也不起作用。任何想法的人。干杯。

【问题讨论】:

    标签: magento button query-string media pinterest


    【解决方案1】:

    尝试替换

    <a class="pinterest" href="http://pinterest.com/pin/create/button/?url=<?php echo $_product->getProductUrl(); ?>&amp;media=<?php echo $image; ?>&amp;description=<?php echo $_product->getName(); ?>" title="Share on Pinterest">&nbsp;</a>
    

    <a class="pinterest" href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode($_product->getProductUrl()); ?>&amp;media=<?php echo urlencode($image); ?>&amp;description=<?php echo urlencode($_product->getName()); ?>" title="Share on Pinterest">&nbsp;</a>
    

    【讨论】:

    • 这行得通。我之前确实使用了 urlencode,但只在 media 属性上使用,也忘了把它放在 url 属性上。谢谢大佬。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 2013-05-20
    • 1970-01-01
    • 1970-01-01
    • 2012-07-23
    相关资源
    最近更新 更多