Home Forums ASE Support html in image caption

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  Hyun Supul 1 week, 2 days ago.

Viewing 2 posts – 1 through 2 (of 2 total)

  • Author

    Posts

  • #15752

    Reply


    maxkukoy

    Participant

    I am trying to add a hyperlink to an image caption. Is this possible? I can add in html code, but it is not parsed, just display as regular text.

    #15754

    Reply


    Hyun Supul

    Keymaster

    Hi, html code is turned into regular text in caption intentionally. Right now there is no way to get around that.

    However, you can output your own caption by adding a custom action. This is the PHP code. You can put this in your theme’s functions.php file or you can use a plugin into inject custom PHP code.

    add_action( 'aesop_image_inner_inside_bottom', 'my_image_caption', 10, 2 );
    
    function my_image_caption( $atts, $unique ) {
       // do stuff here
       echo '<a href="http://www.yahoo.com">YAHOO</a>"
    }
    

    You have to be careful that this would affect every image component. So you probably want to enter a logic in the function to do different things based on what the image or what the post id is. $atts[‘img’] holds the image URL.

    • This reply was modified 1 week, 2 days ago by  Hyun Supul.
    • This reply was modified 1 week, 2 days ago by  Hyun Supul.

Viewing 2 posts – 1 through 2 (of 2 total)

Reply To: html in image caption