Support

Account

Home Forums Front-end Issues ACF + Backstretch Help

Helping

ACF + Backstretch Help

  • Hey all

    I can’t seem to get backstretch to pull in an image from an image field I’ve created. Tried all 3 options in the image settings (array, url and id)

    here is the bit that’s failing, hope someone might have a suggestion…thanks!

    $image = array( ‘src’ => get_field(‘product_image’));
    wp_localize_script( ‘digital-backstretch-set’, ‘BackStretchImg’, $image );

  • ok, the above is actually working for posts and pages if i use the image field

    but not for taxonomies (I’ve added an image field to taxonomy terms, so I can have a nice hero for taxonomy archives)

    think i need to change this

    $image = array( ‘src’ => get_field(‘product_image’));
    wp_localize_script( ‘digital-backstretch-set’, ‘BackStretchImg’, $image );

    to work with this

    // vars
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;

    // load thumbnail for this taxonomy term (term object)
    $thumbnail = get_field(‘thumbnail’, $queried_object);

    // load thumbnail for this taxonomy term (term string)
    $thumbnail = get_field(‘thumbnail’, $taxonomy . ‘_’ . $term_id);

    but not sure how

    at the moment I’m getting the img showing in backstretch but no src…

    any help appreciated !

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

You must be logged in to reply to this topic.