Title: Using variable (image-id) in function »awesome_acf_responsive_image«
Last modified: March 29, 2020

---

# Using variable (image-id) in function »awesome_acf_responsive_image«

 *  [nickknattert0n](https://wordpress.org/support/users/nickknattert0n/)
 * (@nickknattert0n)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/using-variable-image-id-in-function-awesome_acf_responsive_image/)
 * Hey,
    how can I solve following situation. I have spent hours of looking for 
   an easy way.
 * I have defined variables for acf-fields and acf-subfields. That works quite nice
   and I don’t need to use the loop of »if have rows … the row … etc« for getting
   subfields. For me that helps to keep the acf-fields part clearly arranged across
   the different pages.
 * **How to use the »$image« variable from top instead of »get_sub_field(‘subfield’)«
   in the image-tag »awesome_acf_responsive_image« function which doesn’t work since
   I don’t have the loop for using »get_sub_field«?**
 *     ```
       <?php
         $field = get_field('header-work');
         $image = $field['image']; //acf-image-field is set to return id
       ?>
   
       <section>
         <div class="image">
           <img class="img-fluid" <?php awesome_acf_responsive_image(get_sub_field( 'subfield' ),'thumb-640','2560px'); ?>>
         </div>
       </section>
       ```
   
 * Here is the link to the function
    [https://www.awesomeacf.com/responsive-images-wordpress-acf](https://www.awesomeacf.com/responsive-images-wordpress-acf)
 * Thanks alot for your help!
    Cheers, Nick

The topic ‘Using variable (image-id) in function »awesome_acf_responsive_image«’
is closed to new replies.

 * ![](https://ps.w.org/advanced-custom-fields/assets/icon.svg?rev=3207824)
 * [Advanced Custom Fields (ACF®)](https://wordpress.org/plugins/advanced-custom-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-custom-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-custom-fields/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * 0 replies
 * 1 participant
 * Last reply from: [nickknattert0n](https://wordpress.org/support/users/nickknattert0n/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/using-variable-image-id-in-function-awesome_acf_responsive_image/)
 * Status: not resolved