You are here:  » How do I add an image to an empty image feed?

Support Forum



How do I add an image to an empty image feed?

Submitted by mally on Fri, 2009-05-22 22:34 in

Hello David, I hope your well.

In a new feed added to my site, they only have about 50% of the images, where there's no image, the field is blank. see Newstand Magazines

Is there a way I can set a empty feed to an no image I've got setup?

Thanks Mally

Submitted by support on Sat, 2009-05-23 07:40

Hi Mally,

This is probably best done within the code, displaying your "noimage" image if there is no image value in the feed... For example in html/product.php, the code to display the image is currently as follows, beginning at line 6;

        <?php if ($mainProduct["image_url"]): ?>
          <img width='180' src='<?php print $mainProduct["image_url"]; ?>' alt='<?php print $mainProduct["name"]; ?>' />
        <?php endif; ?>

...so this could be replace with:

        <?php if ($mainProduct["image_url"]): ?>
          <img width='180' src='<?php print $mainProduct["image_url"]; ?>' alt='<?php print $mainProduct["name"]; ?>' />
        <?php else: ?>
           <img width='180' src='/path/to/noimage.jpg' />
        <?php endif; ?>

Similarly in html/featured.php beginning at line 10:

          <?php if ($product["image_url"]): ?>
            <p><a href='<?php print $product["productHREF"]; ?>'><img border='0' height='100' src='<?php print $product["image_url"]; ?>' alt='<?php print $product["name"]; ?>' /></a></p>
          <?php endif; ?>

...REPLACE this with:

          <?php if ($product["image_url"]): ?>
            <p><a href='<?php print $product["productHREF"]; ?>'><img border='0' height='100' src='<?php print $product["image_url"]; ?>' alt='<?php print $product["name"]; ?>' /></a></p>
          <?php else: ?>
             <img height='100' src='/path/to/noimage.jpg' />
          <?php endif; ?>

...and in html/searchresults.php beginning at line 9:

          <?php if ($product["image_url"]): ?>
          <a href='<?php print $product["productHREF"]; ?>'><img border='0' width='80' src='<?php print $product["image_url"]; ?>' alt='<?php print $product["name"]; ?>' /></a>
          <?php else: ?>
             <img width='80' src='/path/to/noimage.jpg' />
          <?php endif; ?>

...however I know your files have been modified significantly already so the above may not apply exactly, but that's the general idea...!

Cheers,
David.

Submitted by mally on Sat, 2009-05-23 08:23

Excellent, thanks David, that worked!