title: How To Append A Randomized or Date-Based Query String to Images
body: <p>Internet Explorer has issues. In this case, caching issues. Images that have been saved to my server, and are referenced in my dynamically generated site (WordPress) display as a "red x" in IE8 when those images are modified somehow, but the URI of the image isn't changed in the code, sometimes.</p>
  
  <p>When I do change the URI of these resources, the images display properly in IE. I therefore want to append a somewhat unique query string to the end of my image URI's (a.k.a. change "graphic.png" to "graphic.png?d=a334bc4zxdg2" (if randomized) or "graphic.png?d=201103091616" (if dated). I am not picky about a randomized query string or "dated" query string - just as long as it's a nice long query string appended to the end of .PNG and .JPG filetypes.</p>
  
  <p>I have attempted to write my own, and am thus extremely humbled. I figure this would be resolved with a preg_replace statement... something along the lines of</p>
  
  <pre><code>&lt;php
  echo preg_replace('(png|jpg)', '$1.?d.=&lt;the-randomizing-or-timestamp-code&gt;','some-subject-I-dont-know-how-to-specify')
  ?&gt;
  </code></pre>
  
  <p>As you can tell from above, I need lots of help writing this code. Please note, I am operating in WordPress, which uses some unique hooks, and I'm trying to apply this to the full content of the body. Thanks SO!</p>
  
  <p><strong>== Update ==</strong></p>
  
  <p>A friend suggests the following:</p>
  
  <pre><code>// Append PNG files with timestamp query string
  function date_images () {
      $new_content = str_replace (".png" ,".png?id=".time() ,$original_content);
      }
  
  add_filter('the_content', 'date_images');
  </code></pre>
  
  <p>Is that on the right path? It doesn't work properly in Wordpress, but makes the content element entirely disappear. Thanks for your help...</p>