Member
Member
nbruley   2012-03-13, 02:22
#1
Hi,

If you want the short question, it is:
Can someone tell me what the equivalent of "getFullImageURL" and "$_zp_current_image->localpath" is without the file name? The functions list is so long and I get confused over actual URL vs gallery URL etc.

The reason behind the question is as follows:

I have kind of a unique situation. I have music files in my gallery, and I would like to have a download link show up that links to a different file, depending on the language. I'm thinking I can accomplish this with the custom data field fairly simply, by adding the alternate language file name in the field, uploading the different file to the same album and leaving it unpublished. Do you think this would work? Something like as follows:

`
<?php
if (file_exists(substr($_zp_current_image->localpath,0,-3)."mp3")) {
$spanishName = $_zp_current_album->getCustomData();
if ($language=="spanish" && !empty($spanishName) && file_exists($spanishName)){ // fix second $spanishName
echo "<img src='/download.png' alt='Download:' />"; //fix
}
else {
echo "<img src='/download.png' alt='Download:' />";
}
}
else {
?>

<img src='/download.png' alt='Download:' />
`
The problem I have is I don't know how to reference the path to the mp3 "image" without the file name included. In other words, can someone tell me what the equivalent of "getFullImageURL" and "$_zp_current_image->localpath" is without the file name? The functions list is so long and I get confused over actual URL vs gallery URL etc.

Thanks much.
Member
Member
sbillard   2012-03-13, 03:49
#2
`getAlbumFolder(WEBPATH).'/'.$album->name.'/'.$image->filename'` will give you a link to the original image.
Member
Member
nbruley   2012-03-13, 17:44
#3
Thanks sbillard. That got me going in the right direction, even though I needed a little different function.

`$album->name` didn't work -- but the following did
`$_zp_current_album->name`

My working code is as follows for anyone interested. You'd have to adapt the force download to your own application. The code to reference the image for a file_exists call is different than the web address, which is what often gets me confused.

`
<!-- Add in MP3 download link if same file name available NB -->

<?php
if (file_exists(substr($_zp_current_image->localpath,0,-3)."mp3")) {
$customName = $_zp_current_image->getCustomData();
$customPathName = substr(htmlspecialchars(getAlbumFolder(WEBPATH).$_zp_current_album->name."/".$customName.".mp3"),1);
$customFullPath = $_zp_current_album->localpath.$customName.".mp3";
if ($language=="spanish" && !empty($customName) && file_exists($customFullPath)){
echo "<img src='/download.png' alt='Bajar' />";
}
else {
echo "<img src='/download.png' alt='Download' />";
}
}
`
Administrator
Administrator
acrylian   2012-03-13, 18:02
#4
You might want to look at the downloadList plugin for the force download.
Member
Member
sbillard   2012-03-13, 19:55
#5
As always, the code we might post on this forum is an example and will have to be changed for the specific circumstance. In this case `$album` was a generic album object. `$_zp_current_album` is a specific object for the "active" album.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.