Get Image Filename, Size and Upload Date

Permalink
Hi, I am trying to modify a block using a template and I need to get some additional information about the items. I need to pull the filename, size and upload date however I'm not sure how to do this. I have tried a few things like:

&filename = ih->getTitle();


However this doesn't work. The current code looks like this:

$ih = Loader::helper("image");
    $page = Page::getCurrentPage();
    foreach($items as $item){            
            $fileObj = File::getByID($item['fID']);
            $thumb = $ih->getThumbnail($fileObj,$thumbWidth,$thumbHeight,true);
            $fullImg = $ih->getThumbnail($fileObj,$imageWidth,$imageHeight,false);
            ?>
                <div class="thumb-item">
                    <a href="<?php echo $fullImg->src?>" class="imagelightbox" data-imagelightbox="gallery<?php echo $bID?>"><p>ygv</p></a>
                </div>
    <?php  
    }

 
siton replied on at Permalink Reply
siton
You really need to echo the upload date? The user or google dont need to know when you added file to your cms.

Use page date publish or add file date attribute if you want more control on meta data (example: picture date: "3.5.2002")

File name - you use cache images: Edit the title (the name could be 6a0e6ddfd049cae42b29ffea20403aaa526.jpeg)

"size" dimentions in pixels not in kb:
width ="<?php echo $thumb->width ?>" 
height="<?php echo $thumb->height ?>


Look her how to add microdata to your pictures:
http://schema.org/ImageObject
wbargent replied on at Permalink Reply
What I want is to get the Image File Size and echo it into a table.
siton replied on at Permalink Reply
siton
Learn more by look at this addon view.php (free addon)
https://www.concrete5.org/marketplace/addons/list-files-from-set1...

Part of the code (you must use "if" - this works only on object). important: You get the size of the original default image (not the cache thumb or thumbs versions).
<?php $img = $page->getAttribute('thumbnail');  ?>
<?php if (is_object($img)): ?>
    $fv = $img->getApprovedVersion();
     ///Get file size
     echo $fv->getSize();


More data:
http://legacy-documentation.concrete5.org/developers/files/files-an...
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi wbargent,

With the file object, you can use the getFileName(), getSize(), and getDateAdded() methods on it. The getDateAdded() method returns a DateTime object that has to be formatted.

Example:
$dateAddedObject = $file->getDateAdded();
echo $dateAddedObject->format('Y-m-d H:i:s');

http://documentation.concrete5.org/api/class-Concrete.Core.File.Ver...
http://documentation.concrete5.org/api/class-Concrete.Core.File.Ver...
http://documentation.concrete5.org/api/class-Concrete.Core.File.Ver...
http://php.net/manual/en/datetime.format.php...