This is a very quick post of how I added my Ember feed on the right.
1. The function
Simply use this function I created :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | <?php function ember_thumbs( $options = null ) { # ARE THERE OPTIONS? if( !$options ) return; $feed = 'http://emberapp.com/'.urlencode( $options['username'] ).'/images.rss'; # CREATE NEW DOM DOCUMENT FOR EASE OF PARSING THE FEED $dom = new DOMDocument; # LOAD THE FEED $dom->loadXML( file_get_contents( $feed ) ); # GRAB THE ITEMS FROM THE FEED $images = $dom->getElementsByTagName( 'item' ); $imgs = array(); # LOOP THROUGH EACH OF THE ITEMS foreach( $images as $image ) { # TEMP ARRAY $t = array(); # LOOP THROUGH EACH CHILD NODE foreach( $image->childNodes as $child ) { # IF THE CHILD HAS ATTRIBUTES, SUCH AS THE media:thumbnail TAG if ( $child->hasAttributes() ) { $t[$child->nodeName] = array(); $t[$child->nodeName]['nodeValue'] = $child->nodeValue; $attributes = $child->attributes; foreach( $attributes as $at => $att ) $t[$child->nodeName][$at] = $att->nodeValue; } else $t[$child->nodeName] = $child->nodeValue; } # PUSH THE TEMP ARRAY INTO THE OVERALL ARRAY array_push( $imgs, $t ); } # CONSTRUCT A STRING foreach( $imgs as $image ) if( $i++ < $options['limit'] ) $string .= '<a class="ember_image" href="'.$image['link'].'" title="'.$image['title'].'"><img src="'.$image['media:thumbnail']['url'].'" width="'.$options['size'].'" height="'.$options['size'].'" /></a>'; # CLEAR FROM MEMORY unset( $temp ); # RETURN THE STRING return $string; } ?> |
2. Using the function
To use the function, simply parse in an array of options, which are :
- username
- limit
- size
For example :
1 2 3 4 5 6 7 | <?php echo ember_thumbs( array( 'username' => 'curthard89', 'limit' => 6, 'size' => 92 )); ?> |
Username being your username, limit being how many thumbs you want to display and size is the width and height of the image, once thats done, style till your heart is content.
If you have any questions or mods or anything be sure to leave a comment!
you’re fantastic… I will surely use this function in my upcoming website
@webbografico im glad you find it useful. :)
Excellent