Title: Filtering Image Post Format
Last modified: August 21, 2016

---

# Filtering Image Post Format

 *  Resolved [Stuntbox](https://wordpress.org/support/users/stuntbox/)
 * (@stuntbox)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/)
 * I use [ a custom filter](https://gist.github.com/stuntbox/4557917) in functions.
   php to remove hard-coded width and height attributes on images. This is a must
   for implementing responsive designs. But I can’t figure out what function to 
   add this filter to remove them from the image post format. Any ideas?

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Thread Starter [Stuntbox](https://wordpress.org/support/users/stuntbox/)
 * (@stuntbox)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676615)
 * Seriously, does *anyone* know anything about filtering the output of the_post_format_image?
   Currently it generates a fully-formatted string of HTML, including hard-coded
   attributes. Same goes for trying to retrieve just an image URL from get_the_post_meta().
   Applying filters to the_content have no impact, which is bad since there are 
   custom functions and plugins out there that rely on that to do things like remove
   width and height attributes for responsive designs, as well as mass-modify img
   tags for lazy loading. Are we meant to fall back on doing regex’s on the output
   of the_post_format_image to get the various values? Am I missing something obvious
   here? Would really appreciate any feedback at all on this.
 *  [kevinhaig](https://wordpress.org/support/users/kevinhaig/)
 * (@kevinhaig)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676617)
 * You don’t need filters.
 * Just set the image width in css to a percentage and height to auto.
 *  Thread Starter [Stuntbox](https://wordpress.org/support/users/stuntbox/)
 * (@stuntbox)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676618)
 * Sorry, but there are any number of scenarios where that’s a less-than-ideal scenario
   for handling images in a responsive design. We really, really need the ability
   to remove these hard-coded width and height img attributes at the theme level.
 * I see there are apply_filters for ‘content_image’ and ‘content_images’, but I
   haven’t been able to get them to work yet.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676682)
 * > This is a must for implementing responsive designs.
 * *checks her sites* No it’s not. TwentyThirteen defines sizes and yet, as I pull
   up the site on my phone, the images resize. Ditto Genesis’s StudioPress themes.
 *  Thread Starter [Stuntbox](https://wordpress.org/support/users/stuntbox/)
 * (@stuntbox)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676683)
 * I apologize if there was some frustration coming through in the tone of my earlier
   comments. I want to keep this constructive.
 * True, while it isn’t strictly necessary for implementing flexible images, leaving
   presentational attributes hard-coded in markup is far from ideal for a lot of
   RWD scenarios.
 * What I’m curious about is a filter hook that lets theme makers handle post format
   images in a manner similar to what already exists for other images in WordPress,
   rather than having to write another RegEx-style function to process the fully-
   formatted HTML string that’s returned right now by functions like get_post_format_meta()
   and the_post_format_image(). This would ease development for those of us working
   on things like HiDPI image plugins, lazy loading techniques, picture element 
   polyfills, and the like.
 * This hook could exist right now and I’m just missing it.
 *  Thread Starter [Stuntbox](https://wordpress.org/support/users/stuntbox/)
 * (@stuntbox)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676730)
 * It seems what I’m looking for was suggested by Alex King in Trac but not followed
   up on:
 * [http://core.trac.wordpress.org/ticket/19570#comment:148](http://core.trac.wordpress.org/ticket/19570#comment:148)
 * Anyone have any info RE status or any other ideas?
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676731)
 * It looks like that would need a new trac ticket.
 *  Thread Starter [Stuntbox](https://wordpress.org/support/users/stuntbox/)
 * (@stuntbox)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676732)
 * Cool. Not sure if I did this the right way, but here’s a Trac ticket for it:
 * [http://core.trac.wordpress.org/ticket/24162](http://core.trac.wordpress.org/ticket/24162)
 *  Thread Starter [Stuntbox](https://wordpress.org/support/users/stuntbox/)
 * (@stuntbox)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676747)
 * Also, it looks like Alex has added a patch to that ticket.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Filtering Image Post Format’ is closed to new replies.

## Tags

 * [images](https://wordpress.org/support/topic-tag/images/)

 * In: [Alpha/Beta/RC](https://wordpress.org/support/forum/alphabeta/)
 * 9 replies
 * 3 participants
 * Last reply from: [Stuntbox](https://wordpress.org/support/users/stuntbox/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/filtering-image-post-format/#post-3676747)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
