This worked for me.
function remove_width_and_height_attribute( $html ) {
return preg_replace( '/(height|width)="\d*"\s/', "", $html );
}
and then change
wp_get_attachment_image_src( $attachment_id, 'full' );
to
remove_width_and_height_attribute(wp_get_attachment_image_src( $attachment_id, 'full' ));
Related Posts:
- WP 4.4. responsive images browser choosing the “wrong” one
- Remove images (files) that were generated when using add_image_size()
- Using Images in WordPress – Best Practices
- Change html structure of all img tags in WordPress
- How to create thumbnails with a fixed width, so all of them will have the same width?
- Creating a rotating header /image slider using theme customization
- Adding HTML within an image title attribute
- How do I delete thousands of unattached images?
- How to remove link from an image in a post?
- Change html structure of all img tags in WordPress
- Limit author image size
- Setup A Default Featured Image
- What’s the best “insert all images” plugin?
- Any way to “combine” galleries or show multiple galleries as one?
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- Remove image classes from post thumbnail output
- How can I make all post image uploads have data-width and data-height attributes automatically by default?
- Photography Based Design – Multiple Images Per Post
- wp_upload_bits does not retrieve images that do not have an extension
- Get ALT attribute from title post (code not work)
- Image LazyLoad plugin not loading jQuery dependancies with wp_enqueue_script in WP 3.3.1
- How to check for images before echo
- Images give 404 after changing default domain
- Need custom picture field for pages
- Disable save as image on smartphones using all browsers ( chrome, firefox, ie, cm, opera )
- Apply nextgen-gallery lightbox effect [closed]
- How to pass on a value as parameter via url to another page
- How to make image uploads default to full size?
- WordPress 404 Images – Images not found after deleted from media
- Alt attribute is not showing while the value is given in Media
- WooCommerce Variation Swatches and Photos – get attribute thumbnail
- Get “Image CSS Class” value from the Advanced Options section
- Unable to delete images in Media Library
- Dinamically modifying attributes of images on posts
- How to add multiple images in a page
- Only User Upload image Http Error
- Remove “align” attribute on images
- Upload button in metabox not working
- Saving a post, content filtering and user levels
- Slider do not add alt attribute. Cant get alt attribute from a media library!
- How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?
- Why images are disappearing on WordPress web site?
- Img alt tag showing different value then entered
- Featured Image not changing
- Uploaded Media Images on Site
- Retina images – custom syntax for inserting images into post content
- show author image in posts
- Replace Woocommerce Images
- Dynamically add titles to post images if they are empty
- Automatically wrap post image in div
- SSL: How to make customizer images Protocol Relative in WordPress?
- Is there a way to pull the first featured image in a loop and not all other featured images?
- Image Editor does not affect custom sizes!
- Change the URL of an image from wp_get_attachment_image_src
- Do I need to resize an image to fit the post?
- Some images not found 404 in localhost
- Get Custom Logo Alt Text
- Convert uploaded GIF to non animated image automatically
- Is it possible to split Default WP Media directory to multiple Folder/Subdomain?
- Add srcset and sizes to older uploads?
- Divi Theme – images not showing on front page [closed]
- Edit image results in copies of file being created
- Find and Use an image’s caption
- Export xml use/import images from theme directory
- Is it possible to change image size used for preview thumnail in Add Media popup
- Images showing in editor but not in post [closed]
- Why are featured images sometimes cropped, and sometimes not
- Add clickable link on an image
- How do you import images from a URL in your post?
- Multiple post image, echo url (path of image)
- Make featured image be shareable across multiple pages?
- When the new post which has no image published, save the specific image as the featured image ( by category )
- How do I link a featured photo to it’s post?
- How to indent pictures on WordPress blog? [closed]
- How to test if there are no more previous or next image on attachment page?
- Image and shortcode not showing in excerpt
- What is the plugin to import image from URL?
- problem with add_size_image
- How to enlarge thumbnail on mouseover?
- Images not showing after wordpres update 5.6
- Images names not inserting in WordPress Database from Dynamic Add / Remove fields
- Images do not show in the website, but they appear on new tab
- Image Uploader Doesn’t Open Modal in Widget
- Image linking and lightbox
- Which tools should I use for a gallery that uses an API and url for the path of the images?
- Uploaded images not showing properly using wordpress
- Uploaded images appear broken in WP 4.4
- How to best adjust images to a max content width of 490px?
- Get attachment images does not return any attached images
- attachment.php & flexslider—linking thumbnail to specific image
- Add two images with Sweet Testimonials
- Breadcrumbs for Single Image page
- How to associate an image with a term taxononmy and publish it on frontpage?
- Import existing image as a single post
- How can i make like this structure?
- Stop Attachment image names from taking top level permalink
- Media Library is not loading on grid view in admin panel
- Media upload error
- Featured Image not displaying [closed]
- Profile Image displaying on Wrong side of WordPress Navigation Menu