• Resolved andy85

    (@andy85)


    Hi.

    I have a custom field stored in the product with the image url. Is it possible to display the image within the table via a shortcode. This is what I am trying but can’t get it to work.

    image-1

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter andy85

    (@andy85)

    <img src= " [acf field="image"]" " alt="image-1" width="70" height="50" class="alignnone size-full wp-image-2944" /></a>

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Unfortunately, I have to disappoint you here. From everything I know, this is not possible. This is not a limitation of TablePress though, but related to a change in the Shortcode handling in WordPress. Basically, Shortcode inside such HTML attributes are disallowed for security reasons.

    As an alternative, you could maybe add your own Shortcode with a bit of PHP code (e.g. in your theme’s “functions.php” file):

    add_shortcode( 'andy85_img', 'andy85_image_acf_url' );
    function andy85_image_acf_url( $atts ) {
      return '<img src="' . do_shortcode( '[acf field="' . esc_attr( $atts['field'] ) . '" /]' ) . '" alt="image-1" width="70" height="50" class="alignnone size-full wp-image-2944" /></a>';
    }

    Then, you can put

    [andy85_img field="image" /]
    

    in the table cells.

    Regards,
    Tobias

    Thread Starter andy85

    (@andy85)

    Hi

    Thanks for your very quick response and help, much appreciated.

    I’ve had a go at implementing that code but in the table page it seemS to be just getting a blank square on the table and the image alt alongside. It doesn’t show the image.

    Am I missing something?

    Thanks again

    Andy

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    I don’t really know, I’m afraid… Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!

    Regards,
    Tobias

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘custom field image url via shortcode’ is closed to new replies.