Can anyone help by shedding some light with a little problem I encounter using JSON endpoint requests. I'm not very good with PHP. When the endpoint is called and finds no data, I want to replace it with a local image source. In this case, I am calling brewery->logo_url. Most entries have endpoints, but some don't. When an image link is found at the endpoint, it throws off my layout. You can see the ones that look off. They align to the left. I want to replace with a logo default image each time this happens, with hopes to set the layout adjust back to normal.
Here's my working document http://graintoglass.com/fb/tap-menu-test.php
and here's the JSON. http://mcallen.taphunter.com/widgets/locationWidget?location=Grain-To-Glass&format=jsonv2short
Code Effort
<?php $url = 'http://mcallen.taphunter.com/widgets/locationWidget?location=Grain-To-Glass&format=jsonv2short&servingtype=bottlecan';
$curl_session = curl_init($url);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, 4);
curl_setopt($curl_session, CURLOPT_TIMEOUT, 10);
$data = curl_exec($curl_session);
curl_close($curl_session);
$beer_list = json_decode($data);
echo '<p class="last-updated">Last Updated: ' . date("m/d/Y") . '</p>';
echo '<h1 class="page-title">Bottle List</h1>';
echo '<p class="page-intro">Not only do we serve a hefty list of brews on tap, we also offer an exclusive list of beers in bottle. Our bottle list is constantly changing so the occasional return visits to browse this list is the best way to stay up to date. Take a look!</p>';
foreach ($beer_list as $beer)
{
echo '<article class="beer-entry">
<div class="beer-image"><img src="'.$beer->brewery->logo_url.'" /></div>
<div class="beer-info">
<p class="brewery-name">'.$beer->brewery->name.' — '.$beer->brewery->origin.'</p>
<h2 class="beer-name">'.$beer->beer->name.'</h2>
<p class="beer-style">Beer Style: '.$beer->beer->style.'</p>
<p class="beer-description">'.$beer->descriptions->short_description.'</p>
<p class="beer-abv">ABV: '.$beer->beer->abv.' / IBU: '.$beer->beer->ibu.'</p>
<p class="beer-ibu"></p>
</div>
<div class="clearfix"></div>
</article>
';
}
echo '<p class="page-bottom">If you would like to see more of our food and beer options, <a href="https://www.graintoglass.com" target="_blank">visit our website</a>.</p>';
?>