Jump to content

Images Advice


quickjeff
 Share

Recommended Posts

Hi Guys, 
 
So I am working on a project and wanted to get the best advice using the api on the next step. 

I have two image fields in one template. 

postimage which holds an image for the article and postimage2 which holds an image for the home page.

Basically I want to make it so that when a user uploads postimage and not postimage2 the home page will just pickup postimage instead. 

If the user does upload postimage2, it should pick up postimage2. 

What I did:

I did add a conditional statement to check if postimage2 was empty to simply default to postimage but I was not seeing any images display. 

Here is my code:

<?php  

foreach($featured as $featuredp){

   
 foreach($featuredp->postimage2 as $postimages2) {

        echo"<div class=\"row panel\" style=\"margin:20px auto;\">";
 
echo"<div class=\"large-4 columns\"><p> <a href='{$featuredp->url}'><img src='{$postimages2->url}' width=\"300\"/></a></p></div>"; 

echo"<div class=\"large-8 columns\">

<h4>{$featuredp->title}</h4>
<p><em>{$featuredp->date}</em></p>
<p>{$featuredp->summary}</p>
<p><a href=\"{$featuredp->url}\" class=\"button tiny radius\">Read More</a></p>

        </div>
</div>";


            $found = 1;
            
            
            }

            }
            
         
            if ( ! $found )
            
            {
            
            echo"<p>Sorry, no posts.</p>";
            
            
            }

?>

Any advice is appreciated?  Also any suggestions or workarounds are also welcome!

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