Jump to content

Child page image


closer12
 Share

Recommended Posts

Hi. I am new in process wire. 

I want to show child page image  in the list of child pages as a thumbnail  . ( like title and summary )

I tried this 

<img src='{$child->image_top->url}'>

it works but i want to show ( 300x300 px ) 

I am adding the code below. 

My image field name is : image_top

<?php 

// Output navigation for any children below the bodycopy.
// This navigation cycles through the page's children and prints
// a link and summary: 

if($page->numChildren) {

echo "<ul class='nav'>";

foreach($page->children as $child) {
echo "<li> <img src='{$child->image_top->url}'> <p><a href='{$child->url}'>{$child->title}</a><br /><span class='summary'>{$child->summary}</span></p></li>";}

echo "</ul>";
}
?>
Link to comment
Share on other sites


// without testing, but you can get the idea here

foreach ($page->children as $child) {

$image = $child->image_top;

$thumb = $image->size(300,300);

echo "<li>";

echo "<img src='{$thumb->url}'>";

echo "<p>";

echo "<a href='{$child->url}'>";

echo $child->title;

echo "</a>";

echo "<br />";

echo "<span class='summary'>";

echo $child->summary;

echo "</span>"

echo "</p>"

echo "</li>";

}

  • Like 1
Link to comment
Share on other sites

Thank you for your message, it was inspiration for me, when there is no image it gave error and i added if ..

i did some thing like this and it works fine.....  just can you check if its good?

if($page->numChildren) {

echo "<ul class='nav'>";

foreach($page->children as $child) {
					
if ($child->image_top) {
    $image = $child->image_top;
    $thumb = $image->size(200,200);

echo "<li> <a href='{$child->url}'><img src='{$thumb->url}'></a>  <p><a href='{$child->url}'>{$child->title}</a><br /><span class='summary'>{$child->summary}</span></p></li>"; 
					}}

					echo "</ul>";
				}
  • Like 1
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...