Struggling to identify path to an Image filr
Permalink
Hi!
I have a gallery block that I have downloaded, and I am modifying it to suit my needs. What I am doing is using it to call a single page where the selected thumbnail image can be viewed full size.
I have worked out a method to pass the image filename from the gallery to the single page in this instance 'slp-h3.jpeg', but cannot work out how to identify the full path for the image file, i.e. '/files/9213/5263/8563/slp-h3.jpeg'. I cannot work out why C5 puts the files in such a long filepath.
Any help that can be given will be very much appreciated.
Thanks in advance
Simon.
I have a gallery block that I have downloaded, and I am modifying it to suit my needs. What I am doing is using it to call a single page where the selected thumbnail image can be viewed full size.
I have worked out a method to pass the image filename from the gallery to the single page in this instance 'slp-h3.jpeg', but cannot work out how to identify the full path for the image file, i.e. '/files/9213/5263/8563/slp-h3.jpeg'. I cannot work out why C5 puts the files in such a long filepath.
Any help that can be given will be very much appreciated.
Thanks in advance
Simon.
Note that the ->getPath() method returns the file path on the server, but if you want a URL to the image, use ->getRelativePath()
(both are useful in different situations -- the server path if you want to manipulate the file server-side or examine its size, etc. -- or the URL path if you want to display or link to the file/image from the browser).
As for why the file goes into such a weird place... it's how the C5 File Manager works. It doesn't just put all uploaded files into one directory because then you would accidentally overwrite other files that happen to have the same name. Those numbered directories are based off a timestamp (of when the file was uploaded) I believe.
(both are useful in different situations -- the server path if you want to manipulate the file server-side or examine its size, etc. -- or the URL path if you want to display or link to the file/image from the browser).
As for why the file goes into such a weird place... it's how the C5 File Manager works. It doesn't just put all uploaded files into one directory because then you would accidentally overwrite other files that happen to have the same name. Those numbered directories are based off a timestamp (of when the file was uploaded) I believe.
Thanks chaps! It has given me some ideas of where to start looking...
Both give the path to the parent of the individual file paths but not to the subfolders of where the files are actually located. It has given me food for thought, but if it is possible to either find the path from the thumbnail in the gallery or by interrogating the database(s)?
Apologies for my ignorance with this...
Both give the path to the parent of the individual file paths but not to the subfolders of where the files are actually located. It has given me food for thought, but if it is possible to either find the path from the thumbnail in the gallery or by interrogating the database(s)?
Apologies for my ignorance with this...
Calling $f->getPath() or $f->getRelativePath() should give you the path or URL to the file itself, not just the parent directory.
And how exactly are you showing the thumbnail on the original page? Are you using the image helper's getThumbnail() function? Or do you have a separate image file that is used for the thumbnail?
If you provided some code you're using, that would help clarify what the problem is for us, which would then help us help you better.
And how exactly are you showing the thumbnail on the original page? Are you using the image helper's getThumbnail() function? Or do you have a separate image file that is used for the thumbnail?
If you provided some code you're using, that would help clarify what the problem is for us, which would then help us help you better.
Thanks Jordan. I have just looked at the Gallery page on the C5 website and have seen that you have developed it. It is your Sortable FancyBox Gallery...
I am working in the view.php file. I dont think I have, but apologies if I have contravened any licencing...
I am working in the view.php file. I dont think I have, but apologies if I have contravened any licencing...
No worries about licensing -- assuming you're just building websites with it (and not re-packaging it for further sale), I don't care what you do with it.
As for your specific problem, just knowing what addon you're using doesn't help me understand it better -- if you can provide some code that you're trying to use, and explain which image is where and then where you're grabbing that image from, that would really help clarify what's going on.
As for your specific problem, just knowing what addon you're using doesn't help me understand it better -- if you can provide some code that you're trying to use, and explain which image is where and then where you're grabbing that image from, that would really help clarify what's going on.
Thanks :-)
Here is the code:
My idea is when the thumb is selected it then calls a single page called 'fsimage.php' and I am using the URL to pass the filename (and path) of the image to display. The reason for using a single page is that when the image is selected the user can then have the option of selecting the image for purchase if they want. I thought it would be easier to do this from a single page.
I hope I am making sense here...
Here is the code:
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $html = Loader::helper('html'); $column_width = (100 / $displayColumns) . "%"; $rel = "responsive{$controller->bID}"; //Avoid conflict with other js lightboxes, and isolate each block's prev/next nav to one gallery only. $c = Page::getCurrentPage(); ?> <div class="sortable_responsive_gallery_container"> <?php foreach ($images as $img): ?> <?php $f = File::getByID($fileID); $relpath = $f->getRelativePath(); $path = $f->getPath(); ?> <div class="sortable_responsive_gallery_image" style="width: <?php echo $column_width; ?>;">
Viewing 15 lines of 22 lines. View entire code block.
My idea is when the thumb is selected it then calls a single page called 'fsimage.php' and I am using the URL to pass the filename (and path) of the image to display. The reason for using a single page is that when the image is selected the user can then have the option of selecting the image for purchase if they want. I thought it would be easier to do this from a single page.
I hope I am making sense here...
What are you expecting this line to do, and how are you expecting it to work?
<?php $pagefile="fsimage/?".$path.$img['title']; ?>
It sets up the path and filename for the image to be opened on the single page fsimage (fsimage.php). I am then extracting this information from the URL to display the full size image.
There is probably a much easier way of doing it than I am...
There is probably a much easier way of doing it than I am...
I think the problem with your code is that you're trying to get a file with File::getByID($fileID), but there is no $fileID. The image data that Sortable Fancybox Gallery provides in the template is just the image src's, titles, widths and heights.
You'll need to modify the view() function in the block controller to make more file info available -- for example, you could add these new lines of code directly above the existing "$images[] = $image;" line:
...then in your template, you can get rid of this code:
...and instead just reference $img['relpath'] and $img['path'] when you output the link.
You'll need to modify the view() function in the block controller to make more file info available -- for example, you could add these new lines of code directly above the existing "$images[] = $image;" line:
$image['relpath'] = $file->getRelativePath(); $image['path'] = $file->getPath();
...then in your template, you can get rid of this code:
<?php $f = File::getByID($fileID); $relpath = $f->getRelativePath(); $path = $f->getPath(); ?>
...and instead just reference $img['relpath'] and $img['path'] when you output the link.
BINGO!
Thanks Jordan, that has worked perfectly!!!
Thanks Jordan, that has worked perfectly!!!
http://www.concrete5.org/documentation/developers/files/files-and-f...