helmut2509 Posted January 7, 2014 Share Posted January 7, 2014 I have a page on which I want to display an image.So I created a field 'images' with field type 'image' and added it to the page template.Maximum files set to 3.Image was uploaded and properly stored in filesystem and database.In the template file I have this command img src="<?php echo $page->images[0]->url ?>.. ..but the image does not show up.The URL generated was just "/ProcessWire/" (root directory of the app).Strange thing is thatecho $page->images->url... (shouldn't it be an array?)produces "/ProcessWire/site/assets/files/1/" ...which is better than the former one,but still filename is missing.any suggestions? Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 7, 2014 Share Posted January 7, 2014 Have a look at /api/fieldtypes/images/ Link to comment Share on other sites More sharing options...
kongondo Posted January 7, 2014 Share Posted January 7, 2014 (edited) You sort of answered your question ... ...arrays...http://processwire.com/api/fieldtypes/images/ Hint..."foreach...." ;-) ...Edit...am too slow...Martijn beat me to it Edited January 7, 2014 by kongondo Link to comment Share on other sites More sharing options...
helmut2509 Posted January 8, 2014 Author Share Posted January 8, 2014 You sort of answered your question ... ...arrays...http://processwire.com/api/fieldtypes/images/ Hint..."foreach...." ;-) ...Edit...am too slow...Martijn beat me to it So it is not possible to get the image url by "$page->images[0]->url" ? foreach only makes sense if all images are handled in the same way. But what if you want to handle the images individually? Link to comment Share on other sites More sharing options...
Soma Posted January 8, 2014 Share Posted January 8, 2014 It's not an regular array but a WireArray. You can use all WireArray methods that are listed on the cheatsheet. $page->images->first->url; $page->images->last->url; $page->images->eq(3)->url; ... 3 Link to comment Share on other sites More sharing options...
helmut2509 Posted January 8, 2014 Author Share Posted January 8, 2014 It's not an regular array but a WireArray. You can use all WireArray methods that are listed on the cheatsheet. $page->images->first->url; $page->images->last->url; $page->images->eq(3)->url; ... thanks Soma, I will try this in the evening. But this is a feature which should also be mentioned in the image-fieldtype documentation... Link to comment Share on other sites More sharing options...
Soma Posted January 8, 2014 Share Posted January 8, 2014 If you follow and read the link martijn and kongondo posted http://processwire.com/api/fieldtypes/images/ you'll see that it's actually all there mentioned. 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