OpenBayou Posted January 1, 2017 Posted January 1, 2017 Hey everyone, I'm new at using ProcessWire and starting to get a better understanding at how this works (and enjoying what I see). However, I'm having problems with displaying images on my theme. The field is called 'Image' and I'm looking for ways to display the URL to the image attached to the page. This is the code I have so far: <?php foreach($pages->find("parent=recommendations") as $child) { ?> <?php echo $child->title;?> <?php } ?> First thing I'm having problems with is displaying the image. If I do `<?php echo $child->Image;?>' it just shows the filename.jpg. If I do '<?php echo $child->Image->url;?>`, it just shows the directory (/site/assets/files/1110/). First question is i'm looking for a way to display the full path of the image. Second question I have is how do you show different sizes of the image. Thanks and happy new year.
Mats Posted January 1, 2017 Posted January 1, 2017 Hi! If you have an array of images, try this: $child->image->first()->url $child->image->first()->size(200,200)->url 2
Klenkes Posted January 1, 2017 Posted January 1, 2017 The slightly longer version... where (200,200) means an image width 200px in width and height, croped from the center. (200,0) would result in an image 200px in width and whatever results in the height A good starting point would be the doc to the fieldtype images 3
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