Jump to content

Coding a default image?


ArchangelX

Recommended Posts

Posted

Hi, I'd like to code a default image in case someone doesn't upload an image. 

Does anyone know how to add in a Default Image if the member doesn't upload one?  I'm using this for a database using custom fields.

I assume I'll need to add to this code with an elseif statement since I have more than two images to choose, but I'm not sure how to write a direct url into it?  

<a href="{$record->url()}" style="background-image: url({{if ($id == 0)}}{file='$record->field_19' extension='cms_Records'}{{else}}{file='$record->record_image_thumb' extension='cms_Records'}{{endif}}); width:100%;">

I've written as such elsewhere but not sure how to add this into that type of coding...

<a href="{$record->url()}" title="{lang="read_more_about" sprintf="$record->_title"}"><img class="ipsUserPhoto" src="http://www.xxxx.com/defaultimage.jpg"></a>

Can anyone help me write this appropriately?

Posted

It’s not the only way to do it, but I am just pasting my code snippet here where I did exactly what you are asking for. 

 {{if $row->field_52}}
    <a href='{$row->url()}'><div style='background-image:url({file="$row->field_52" extension="cms_Records"});'></div></a>
  {{else}}
    <a href='{$row->url()}'><div style='background-image:url(http://typography.guru/xmodules/assets/noimage.png);'></div></a>
{{endif}}

 

Posted

Urgh, I can't get it to work.  I tried copying and modifying your string to fit mine, but no jive. Then I tried replacing the code in different ways.

I just want to replace field_xx with a direct url in the existing string. Any further ideas?  See, it's a little different because it's using a background url that is using an else statement within the code.  So it has to work as so....

<a href="{$record->url()}" style="background-image: url({{if ($id == 0)}}{file='$record->field_19' extension='cms_Records'}{{else}}{file='$record->record_image' extension='cms_Records'}{{endif}}); width:100%;">

I want to replace the second bit after the else statement.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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