Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
In ttg_single_bottom I can figure out how the get the URL of the image php file but is there and easy way to get the URL of the actual image itself?
Thanks.
Charlie
www.stalkinglight.com
Offline
Unfortunately, the image name or any additional image data are not exposed by the phplugins API. But at least from the page URL, it is easy to derive the image filename and then create the image path.
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Thanks. I was hoping I could be lazy and not have to parse everything. ?
Charlie
www.stalkinglight.com
Offline
Little coffee break exercise. Might not be the most efficient, but it works:
function ttg_single_bottom( $style, $path) {
$img = substr(strrchr(substr($_SERVER["REQUEST_URI"], 0, strrpos($_SERVER["REQUEST_URI"],"-single.php")), '/'), 1);
$imgpath = substr($_SERVER["REQUEST_URI"], 0, strrpos($_SERVER["REQUEST_URI"],$img)) . 'photos/' . $img . '.jpg';
echo '<a href="'.$imgpath.'">'.$imgpath.'</a>';
}
You are not working on 'share to social media' buttons by chance?
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Thanks for the code and, yes I am. I can share the php link to fb and g+ but some need a link to the jpg itself.
Charlie
www.stalkinglight.com
Offline
Hey Charlie, would you mind to share your code that you came up with? Thank you!
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
This is probably a little clunky but it seems to work ok.
function ttg_single_bottom ( $style, $path ) {
$actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$img = substr(strrchr(substr($_SERVER["REQUEST_URI"], 0, strrpos($_SERVER["REQUEST_URI"],"-single.php")), '/'), 1);
$imgpath = substr($_SERVER["REQUEST_URI"], 0, strrpos($_SERVER["REQUEST_URI"],$img)) . 'photos/' . $img . '.jpg';
$imgfullpath = "https://$_SERVER[HTTP_HOST]$imgpath";
echo '
<div id=social-align>
<a class="icon" target="_blank" href="http://www.facebook.com/sharer/sharer.php?u='.$actual_link.'" title="Share on Facebook">
<i class="fa fa-facebook-official" style="color:#3b5998; font-size: 150%;"></i></a>
<a class="icon" target="_blank" href="http://www.twitter.com/intent/tweet?url='.$actual_link.'" title="Tweet">
<i class="fa fa-twitter" style="color:#1da1f2; font-size: 150%;"></i></a>
<a class="icon" target="_blank" href="https://plus.google.com/share?url='.$actual_link.'" title="Share on Google Plus">
<i class="fa fa-google-plus-official" style="color:#dd4b39; font-size: 150%;"></i></a>
<a class="icon" target="_blank" href="http://pinterest.com/pin/create/button/?url='.$actual_link.'&media='.$imgfullpath.'" title="Share on Pinterest">
<i class="fa fa-pinterest-p" style="color:#cb2027; font-size: 150%;" id="social_media_04"></i></a>
<a class="icon" target="_blank" href="http://stumbleupon.com/submit?url='.$imgfullpath.'" title="Share on Stumbleupon">
<i class="fa fa-stumbleupon" style="color:#EB4823; font-size: 150%;" id="social_media_04"></i></a>
<a class="icon" target="_blank" href="mailto:?subject=An image you might like&body='.$actual_link.'" title="Share via email">
<i class="fa fa-envelope-o" style="font-size: 150%;"></i></a>
</div>
';
}
Charlie
www.stalkinglight.com
Offline
Thank you, Charlie!
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Charlie, there was a missing '/' in the stumbleupon.com link. I fixed it in the code you posted.
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
Thanks Daniel, I should have caught that.
Charlie
www.stalkinglight.com
Offline
Thanks Daniel, I should have caught that.
Somehow it works on your site, but didn't on mine.
Daniel Leu | Photography
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com
Offline
FWIW, this is the css styling I used:
#social-align
{
text-align: right;
float: none;
padding-right: 24px;
}
#social-align.icon {
display: inline-block;
}
Charlie
www.stalkinglight.com
Offline