Jump to content

Recommended Posts

Posted

I've created my first field an image field called Main image which will live above the headline. I managed to create the field and add the field to the template. But nothing is showing?

What have I done wrong?

Posted

Hi sa_designer and welcome to the forums!

I've created my first field an image field called Main image which will live above the headline. I managed to create the field and add the field to the template. But nothing is showing?

Images (and files) are little bit different from text-based fields. Here is topic which helps you forward: http://processwire.com/talk/index.php/topic,16.0.html and even more information from here: http://processwire.com/api/fieldtypes/images/

Also one way to show images are when using TinyMCE field - just click image field and choose the image. But best use is usually in templates.

Posted

Welcome to the forums :)

Can you show us the code you're using in your front-end template file? Then we might be able to see what the issue is and point you in the right direction.

Posted

Welcome to forums, SA_DESIGNER

You should write  a couple of lines of code in your template to output your image.

Your code should go something like this:

 if (count($page->images)){
    foreach ($page->images as $image) {
        
        echo "<img src='{$image->url}' alt='{$image->description}'</img>";
        
    }    
}

Replace images with the name of your image field.

See site/templates/basic-page.php and head.inc for an example with thumbs.

Cheers.

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...