Jump to content

selector image field


diegonella
 Share

Recommended Posts

It's hard to understand what exactly you want to do. Can you also try to put some spaces between your words? Thx.

You can grab an image using the image field name. If its setting is to allow only a single image file you can do:

// single image field
echo $pageobject->imagefield->url;
echo $pageobject->imagefield->size(100,100)->url;

If the image field is set to allow multiple images, you must use a loop to cycle through them, or chose the first, or maybe a random one.

// multiple
foreach($page->imagesfield as $img){
$thumb = $img->size(100,100)->url;
echo "<img src='$thumb' />";
}
// or chose first from image array
$page->imagesfield->first->url;

// or random
$page->imagesfield->getRandom(1)->url;

// grab pages using a special template and output a list of their images.
$pa = $pages->find("template=yourtemplate");
echo "<ul>";
foreach($pa as $p){
   $thumb = $p->imagefield->width(100)->url;
   echo "<li><img src='$thumb'/></li>";
}
echo "</ul>";

Does that help you? If not can you provide better and more information what you want to do?

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

  • Recently Browsing   0 members

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