pinterest

Permalink
Hi,
I have added a pinterest functionality to a website.
In a custom feature block I have svg images which I would like to exempt from pinterest.
To do this, I need to add nopin="nopin" to my generated image tag:
<?php
if (is_object($f)) {
$image = Core::make('html/image', array($f));
$tag = $image->getTag();
}
$tag-> addClass('image-icon bID-'.$bID);
print $tag;
?>
How do I do this? My php scripting ability is limited, and I would really appreciate some help with this ...

Thanks,
Una

 
mnakalay replied on at Permalink Reply
mnakalay
this should do the trick
$tag->setAttribute('nopin', 'nopin');


Oh and your code needs some tweaking. It should be like this
<?php
if (is_object($f)) {
    $image = Core::make('html/image', array($f));
    $tag = $image->getTag();
    $tag-> addClass('image-icon bID-'.$bID);
    $tag->setAttribute('nopin', 'nopin');
    print $tag;
}
?>
fatcatsanonymous replied on at Permalink Reply
Hi,
Thanks so much for your time on this.
The code works perfectly to add the attribute to the picture tag, but unfortunately, it seems it needs to be within the image tag to work.

My html output now is:
<picture nopin="nopin">
<img src="#" alt="#" class="#">
</picture>


what I need is this:
<picture>
<img src="#" alt="#" class="#" nopin="nopin">
</picture>


Thanks,
Una
mnakalay replied on at Permalink Best Answer Reply
mnakalay
I see. Try this

<?php
if (is_object($f)) {
    $image = Core::make('html/image', array($f, false));
    $tag = $image->getTag();
    $tag-> addClass('image-icon bID-'.$bID);
    $tag->setAttribute('nopin', 'nopin');
    print $tag;
}
?>

Be warned that it will remove the <picture> tag to only keep the <img> tag so if you need the picture tag for responsve reasons it might be a problem.
But if the result you posted is complete, you don't really need that picture tag.
fatcatsanonymous replied on at Permalink Reply
Perfect, Thank You!