Title: Customize shortcode function for inserting an image
Last modified: August 24, 2016

---

# Customize shortcode function for inserting an image

 *  [len7227](https://wordpress.org/support/users/len7227/)
 * (@len7227)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/customize-shortcode-function-for-inserting-an-image/)
 * Hello!
 * I am trying to customize a given function for shortcode about a banner. The banner
   contains a title and a subtitle.But I want to add an image left to the title.
   the function is like this:
 *     ```
       function banner($atts,$content=null){
           ob_start();
       extract(shortcode_atts(array("title" => '', 'subtitle'=>'', 'type'=> ''), $atts));
   
           if($type == 2){
       	   return '<div id="banner" class="banner-2">
                   <div class="site-slogan">
                       <div class="slogan-inner clearfix">
                           <h2>'.$title.'</h2>
                           <h2>'.$subtitle.'</h2>
                       </div>
                   </div>
               </div>';
           }
       ```
   
 * I want to insert <img src=”…”> so when I want to edit the section(it’s one page
   parallax theme)i will be able to add/change an image dynamically.
    I tried <img
   src=’.$content.’> but it’s not working. Should I add another variable(image) 
   to the function like title and subtitle? of cource i have to customize and the
   css file properly. but all i see in my page is a broken image, which means that
   it doesn’t take the parameter value!
 * I hope someone could help me!

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/customize-shortcode-function-for-inserting-an-image/#post-6061841)
 * The way you have defined the function, $content would be contained between opening
   and closing tags for the shortcode. So, if the shortcode is `[myimage]`, the 
   value of $content would be whatever is between `[myimage]` and `[/myimage]`.
 * You might have better luck making ‘content’ a variable as you suggested.

Viewing 1 replies (of 1 total)

The topic ‘Customize shortcode function for inserting an image’ is closed to new
replies.

## Tags

 * [insert image](https://wordpress.org/support/topic-tag/insert-image/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/customize-shortcode-function-for-inserting-an-image/#post-6061841)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
