Reputation: 4186
I have a Magento store at http://www.harmonics.co.uk and I have PinIt buttons on products.
The problem is when you click it, it does not pick up the image from the media attribute in the query string, even though the URL is correct.
I'm using the following code to generate my image and the PinIt button on product pages:
<?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(); ?>&media=<?php echo $image; ?>&description=<?php echo $_product->getName(); ?>" title="Share on Pinterest"> </a>
It used to work but I think Pinterest have changed the way their buttons work but I can't see how. The generated code looks almost the same, except that generated URL's replace : with %3A and / with %2F.
I've tried doing a string replace but this doesn't work either. Any ideas folks. Cheers.
Upvotes: 1
Views: 1453
Reputation: 546
try replacing
<a class="pinterest" href="http://pinterest.com/pin/create/button/?url=<?php echo $_product->getProductUrl(); ?>&media=<?php echo $image; ?>&description=<?php echo $_product->getName(); ?>" title="Share on Pinterest"> </a>
with
<a class="pinterest" href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode($_product->getProductUrl()); ?>&media=<?php echo urlencode($image); ?>&description=<?php echo urlencode($_product->getName()); ?>" title="Share on Pinterest"> </a>
Upvotes: 5