Skip to content

Instantly share code, notes, and snippets.

@jonsuh
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonsuh/9981407 to your computer and use it in GitHub Desktop.
Save jonsuh/9981407 to your computer and use it in GitHub Desktop.
Chris Coyier RSS Email with Simple HTML DOM example
require_once('Simple_HTML_DOM.php');
$post_html = "<p>Some random sentence or whatever.</p>
<figure id='post-167550 media-167550' class='align-none'>
<img src='http://css-tricks.com/wp-content/uploads/2014/04/concept.png' alt='' />
</figure>
<p>Another random sentence or whatever.</p>
<figure id='post-167550 media-167550' class='align-none'>
<img src='http://css-tricks.com/wp-content/uploads/2014/04/concept.png' width='500' height='200' alt='' />
</figure>";
$post_html_raw = str_get_html($post_html);
foreach($post_html_raw->find('img') as $image) {
$image_src = $image->src;
$image->width = '320';
$image->height = '';
}
echo $post_html_raw;
@jonsuh
Copy link
Author

jonsuh commented Apr 4, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment