Manaus Posted February 28, 2014 Share Posted February 28, 2014 Hello, I'm trying to hack this thing, witout success... echo $page->documents; // selfie.jpg echo $page->documents->description; // no echo $page->documents->get("description"); // no $f = $fields->get("documents"); echo $f->description; // neither Thanks for any suggestion... Link to comment Share on other sites More sharing options...
adrian Posted February 28, 2014 Share Posted February 28, 2014 echo $page->documents->description; should work just fine. I think it is likely your documents field is set to handle more than one image, so you will need: echo $page->documents->first()->description; I just did a little testing a noticed something slightly unexpected. When there is one image in the field you get: echo $page->documents; //selfie.jpg echo $page->documents->first(); //selfie.jpg echo $page->documents->url; //site/assets/files/xxxx/ echo $page->documents->first()->url; //site/assets/files/xxxx/selfie.jpg echo $page->documents->first()->description; // image description echo $page->documents->description; // blank With two images in the field, you get: echo $page->documents; //selfie.jpg|selfie2.jpg So I guess I had never noticed that you actually get the filename returned from a files array. I would have expected an error with: echo $page->documents; 3 Link to comment Share on other sites More sharing options...
kongondo Posted February 28, 2014 Share Posted February 28, 2014 (edited) Get the image, then echo its description...e.g. $images = $page->photos->find("sort=name"); foreach ($images as $image) { echo $image->description; } The above assumes multiple images/array...if not, just echo directly without foreach. Code also assumes you have a field called photos. The code can be shortened too - so you are on the right track but probably need to iterate an array... http://processwire.com/api/fieldtypes/images/ Edit: Adrian was faster Edited February 28, 2014 by kongondo 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now