Support

Account

Home Forums Front-end Issues WordPress 4.4 responsive images Reply To: WordPress 4.4 responsive images

  • I found a solution so that ACF creates the correct code from a WYSIWYG field. You only have to add

    add_filter( 'acf_the_content', 'wp_make_content_images_responsive' );

    to your functions.php. I hope Elliot will add this direct into the code, so that ACF filters the WYSIWYG content like WP does.

    For the image field this code works for me:

    $image = get_field('my_image');
    $img_src = wp_get_attachment_image_url( $image['id'], 'full' );											$img_srcset = wp_get_attachment_image_srcset( $image['id'], 'full' ); ?>
    											<img src="<?php echo esc_url( $img_src ); ?>"
    	width = "<?php echo $image['sizes']['Stripe-width']; ?>"
    	height = "<?php echo $image['sizes']['Stripe-height']; ?>"
    	srcset="<?php echo esc_attr( $img_srcset ); ?>"
    	sizes="(max-width: 100vw) 480px" alt="<?php echo $image['alt']; ?>"
    >