Shortcode help: If no image entered take default

I have a shortcode that creates an “opinion box”.

The user should insert 4 parts

Read More
  1. the title
  2. the images
  3. the opinion
  4. side of the image in relationship with text

i want to check if no image was entered and in such
a case take a default image from /images/ folder…
but to do so without changing the ‘paste Img Url’
statement which i need in order to explain to the
user where to put the image if exists.

This is the shortcode:

function opinionBox( $atts, $content = null ) {
    extract( shortcode_atts( array(
        'title' => 'yourtitle',
        'imgURL' => 'paste Img Url',
        'side' => 'left'
    ), $atts ) );

    return '
    <div class="opinionBOX">
        <div style="float: '. $side .';" class="myimg">
        <img alt="'. $title .'" src="'. $imgURL .'">
        </div>
        <div class="speakerBOX">
            <span class="highlight_black">'. $title .'</span><p></p>
            '. $content .'
        </div>
        <br style="clear: right;">
    </div>
    ';
}
add_shortcode( 'opinionbox', 'opinionBox' );

Related posts

Leave a Reply

1 comment