Title: Image Shortcode in Post
Last modified: September 1, 2017

---

# Image Shortcode in Post

 *  [guennionline](https://wordpress.org/support/users/guennionline/)
 * (@guennionline)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/image-shortcode-in-post/)
 * Is there a way to display an image by shortcode in an automatically generated
   post from a publication? So to integrate the picture automatically in the contribution
   template?
 * greetings
    Guenni
 *     ```
       [tpsingle [key]]<!--more-->
   
       [tpabstract]
   
       *Picture Here*
   
       [tplinks]
       ```
   
 * WordPress 4.8.1
    teachPress 6.1.0
    -  This topic was modified 8 years, 9 months ago by [guennionline](https://wordpress.org/support/users/guennionline/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [winkm89](https://wordpress.org/support/users/winkm89/)
 * (@winkm89)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/image-shortcode-in-post/#post-9467231)
 * Hi,
 * The following code should add an [tppubimage] shortcode. You can add the code
   to the functions.php of your theme or create a new plugin with it:
 *     ```
       /** 
        * Shortcode for displaying the image of a single publication
        * 
        * possible values of $atts:
        *      id (INT)        id of a publication
        *      key (STRING)    bibtex key of a publication 
        * 
        * If neither is given, the publication of the most recent [tpsingle] will be reused
        * 
        * @param array $atts
        * @return string
       */ 
       function tp_pubimage_shortcode ($atts) {
           global $tp_single_publication;
           $param = shortcode_atts(array(
              'id' => 0,
              'key' => '',
           ), $atts);
   
           $publication = tp_shortcodes::set_publication($param, $tp_single_publication);
   
           if ( isset($publication['abstract']) ) {
               return '<img src="' . tp_html::prepare_text($publication['image_url']) . '" alt=""/>';
           }
           return;
       }
   
       add_shortcode('tppubimage', 'tp_pubimage_shortcode');
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Image Shortcode in Post’ is closed to new replies.

 * ![](https://ps.w.org/teachpress/assets/icon-256x256.png?rev=1110789)
 * [teachPress](https://wordpress.org/plugins/teachpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/teachpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/teachpress/)
 * [Active Topics](https://wordpress.org/support/plugin/teachpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/teachpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/teachpress/reviews/)

## Tags

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

 * 1 reply
 * 2 participants
 * Last reply from: [winkm89](https://wordpress.org/support/users/winkm89/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/image-shortcode-in-post/#post-9467231)
 * Status: not resolved