Jump to content

Recommended Posts

Posted

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.

Posted

Hi!

If you have an array of images, try this: 

$child->image->first()->url
$child->image->first()->size(200,200)->url
  • Like 2
Posted

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

  • Like 3

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...