Support

Account

Home Forums ACF PRO Image Field Shortcode As Data-Image-Src

Helping

Image Field Shortcode As Data-Image-Src

  • Hi there,

    I’m using jQuery Parallax and would like to insert an image source into the ‘data-image-src’ attribute, for instance:

    <div class="parallax-window" data-image-src="[acf field='my_image']" data-parallax="scroll" data-z-index="10" data-bleed="10" data-position="top"></div>

    This doesn’t appear to work, but the following does:

    <img src="[acf field='my_image']">

    Could you please let me know how I might accomplish returning the acf image shortcode’s source within a ‘data-image-src’ attribute?

    Thanks in advance!

  • If this is in a template file then you need to use get_field() and not a shortcode. ACF shortcodes only work on simple text fields.

    Unless I’m missing something. Is there some reason that you need to use a shortcode? Is this code not in a template?

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

The topic ‘Image Field Shortcode As Data-Image-Src’ is closed to new replies.