You won’t be really able to tell which context the image is being used in in the wp_get_attachment_image_attributes
filter, but you can pass custom attributes to wp_get_attachment_image()
in the template directly with the 4th argument. Then you can use wp_get_attachment_image_url()
and wp_get_attachment_image_srcset()
to get the values for those attributes:
$image = get_field('image');
$size="gallery";
echo wp_get_attachment_image( $image, $size, false, array(
'src' => '',
'srcset' => '',
'data-flickity-lazyload-src' => wp_get_attachment_image_url( $image, $size ),
'data-flickity-lazyload-srcset' => wp_get_attachment_image_srcset( $image, $size ),
) );
Related Posts:
- Remove Dimension from wp_get_attachment_image
- How do I make a custom field choose an image?
- Extend WP Customizer to make multiple image selection possible
- Add multiple images to a page sidebar
- Display thumbnail from custom field
- Add custom field to image editor
- Display info from custom fields in all images’ HTML
- automatically set “Featured Image” the same as the og:i that is set in a custom field
- copy attachments to another post type and change attachment url
- limit amount of photos uploaded per cpt post
- Metabox with multiple fields added by user and upload box
- Add WYSIWYG to Image Description field
- Get Meta from Custom Field of Image URL
- Add url from Custom Field as ‘Featured Image’. Code not working
- How to display multiple images in custom field
- How to add image attachment to post from a single meta key (Woocommerce)
- Exclude images uploaded via meta boxes from WordPress gallery
- How to add the image URL from an external RSS feed and insert into a custom field?
- Add new image block, set default class name and update it using Javascript
- Better way to save image in custom field
- How do I add an image upload, custom field to a WooCommerce product?
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- Select multiple images from custom field
- Displaying page image in the footer automatically
- Get image url using image id
- Show image if author meta (profile fields) exists outside loop
- Convert attachment ID into url?
- Custom field as featured image caption
- Display a different image for each page with editor
- Image upload and path to custom field
- How to get custom image field of specific post id
- Selectively hiding or allowing thumbnails of featured images on front page
- wp_get_attachment_image_src() with advanced custom fields returning empty
- Unable to select image with custom field
- Users uploaded image and matching an id or taxonomy
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- Show image depending on the number in the custom fields
- How to delete attachments associated with custom field type when post property changes? [closed]
- Use a different catalog image than the featured image
- How to add custom fields to images for image source text and URL
- Get first URL from custom field, download and set as featured image on post publish
- Change path to child of page when uploading image via custom field
- Analyze uploaded images to get colour values
- Adding thumbnails for non-image attachments
- Upload image to wordpress
- Undefined Variable (Displaying image via custom field)
- Multiple image uploader under editor?
- Get single image from custom fields made with WCK custom fields creator
- Add image custom attribute [closed]
- How to mark a image attachment as background image?
- Crop custom image size vs actual size
- Preserving line breaks when saving and displaying custom fields data
- How to delete custom field “suggestions” from dropdown list
- How to get a meta value from all post
- Adding existing user custom field value to a woocommerce product [closed]
- How to save values of a custom input field on the Network > Site Info screen
- How to load php file for specific page in admin?
- ajax jquery update custom field meta value front end
- get_post_meta not working inside loop
- How do I exclude posts by custom field value?
- Auto populate a meta box field from another meta box field when publish or save
- Eliminating the appearance of a specific custom field in a post
- Conditional custom field query
- Display two custom values from a post
- Find page IDs with specific meta tag key value pairs
- Order query by meta_value with multiple custom fields
- Send email with custom fields after new draft is saved or new post published
- Get posts with same meta value as current post
- Add custom field to all posts in specific post_type
- query posts custom field calculation value
- Get Data From wp_sitemeta for Multisite network
- Syntax Issue: How Do I Call A Custom Field Inside a ForEach Statement? [closed]
- Singleton Custom Field (Meta Box)
- How to add fields in custom registration form, validate it and aave to db? [closed]
- How to update a custom field in all posts with the value of another custom field in the same post?
- Best Way to get facebook share count and update using wp_schedule_event or any other method
- Get YouTube video id from url in a custom field
- How to insert multiple checkbox values into post as custom fields from frontend
- Trying to implement AJAX into my admin pages. Am I improperly enqueue and localizing my scripts?
- Fallback for empty custom fields
- Problem with writting correctly a query posts args in WordPress
- Add a field to just ONE page
- get_post_custom_values problem, please help
- How do I upload file through custom field, save it to database and get it
- How To Save Data From Remote APIs To ACF?
- Custom meta fields and meta keys
- HTML for adding a meta box (basic text field) to page editor?
- adding autosave feature to custom fields
- How to delete WooCommerce Products than have a specific custom field?
- Check for meta data before it is published
- update_user_meta(): invisible data storage
- Sort custom fields in admin by last field added
- Call the latest posts from a custom field group to be displayed on front-page
- custom select field populated by allocated post category
- Hard Define Custom Field Value
- How would I attach media/images to a post based on a ID stored in a each post’s custom field
- Basics: adding template tag to display custom fields in the post
- get adjacent post by meta key and meta value
- file upload user profile
- Tons of Custom Fields [closed]