Use image description from the File Library

Permalink
I posted this issue on the DOJO SUPERSIZED forum, but the problem seems to be in connecting with the Description field of the file.

I made a custom template where the Image Description will be visible in a div, just like the script already provides for Slide_Caption (Title). But there is a problem with it.

It should be possible since the controller.php already pulls the description from the File Library (line 56):
$image['title'] = $f->getTitle();
$image['description'] = $f->getDescription();


in view.php I changed line 44 to:
$js[] = "{image : '" . $img['fullSrc'] . "', title : '" . htmlspecialchars($img['title'], ENT_QUOTES, APP_CHARSET) . "', description : '". htmlspecialchars($img['description'], ENT_QUOTES, APP_CHARSET) ."'}";


I changed to code in the file supersized.3.1.3.min.js so the description will be printed as I want. So this is not working, but it DOES work when I change the code in controller.php file, line 56, to:

$image['description'] = "Bla bla bla";


Any suggestions?

 
jordanlev replied on at Permalink Reply
jordanlev
Hard to say without seeing other parts of the code (and what did the Dojo people say about it)? But if setting the description to 'blah blah' works then the problem would probably be that $f->getDescription() is not working -- make sure the files actually have their description properties set.
glockops replied on at Permalink Reply
glockops
I've always had to get the most recent file version, then get the description. I don't think I've ever gotten $f->getDescription() to work.
<?php
$fv = $f->getApprovedVersion();
$desc = $fv->getDescription();
?>

Reference:http://www.concrete5.org/documentation/developers/files/files-and-f...
jordanlev replied on at Permalink Reply
jordanlev
$f->getDescription() should work fine -- I use that in all of my code (including several popular images galleries in the marketplace that have thousands of users).

The docs you reference state that "For convenience, the File object will pass through any methods that it doesn't understand to its currently loaded FileVersion object." This means you can call getDescription() on the file object and because the object itself doesn't have a "getDescription" function it will pass it along to the most recent fileVersion object (and if you look at the code in concrete/models/file.php, you'll see this implemented using the "__call()" magic method).
voltage replied on at Permalink Reply
@Jordanlev
- The images do have a description.
- This is the link to the Dojo forum:http://www.concrete5.org/marketplace/addons/dojo-supersized/forums/...

@glockops I tried it with the getApprovedVersion() code, but it doesn't work..
jordanlev replied on at Permalink Reply
jordanlev
It looks like the dojo guy solved the problem. If not, unfortunately I don't think there's anything anyone else can do, since it's a paid addon (the code is not available for others to look at).