/*
Plugin Name: Distrify Embed
Plugin URI: http://support.distrify.com/customer/portal/articles/264106-how-do-i-embed-on-a-wordpress-blog-
Description: Extends WordPress's Embeds allowing bloggers to easily embed videos from Distrify. Just go to any Distrify film page or player and copy the URL. Paste that URL in any WordPress blog and it will automatically be converted to an embedded Distrify player. If you are logged in to distrify.com it will automatically add your affiliate tracking code to your embeds. Make sure you turn on Auto-embeds in your WP settings and also make sure that the URL is on its own line and not hyperlinked (clickable when viewing the post). The plugin also extracts the still image from the film and saves it as the Featured Image for the post. This actually works for any Embed (not just Distrify) that you embed into your WordPress blog.
Author: Distrify Limited
Version: 0.3.1
Author URI: http://www.distrify.com
License: GPL2
Copyright 2011-2013 Distrify (email : hello@distrify.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Does the work of adding the Distrify provider to wp_oembed
*/
function add_distrify_provider($the_content){
require_once( ABSPATH . WPINC . '/class-oembed.php' );
wp_oembed_add_provider('#https?://(www\.)?(distrify|muvies).com/films/.*#i', 'http://distrify.com/oembed.json', true );
wp_oembed_add_provider('http://muvi.es/*', 'http://distrify.com/oembed.json' );
wp_oembed_add_provider('#https?://.*\.muvies.com/.*reviews/.*#i', 'http://distrify.com/oembed.json', true );
}
//add the provider on plugins_loaded.
add_action('plugins_loaded', 'add_distrify_provider');
/**
* from http://wordpress.stackexchange.com/q/70752/1685
* Automatically set the featured image if an oEmbed-compatible embed is found in the post content.
* author: TheDeadMedic
* author URI: http://wordpress.stackexchange.com/users/1685/thedeadmedic
*
*/
add_action( 'wp_insert_post', array( 'ofi', 'init' ) );
class ofi
{
/**
* The post thumbnail ID
*
* @var int
*/
private $_thumb_id;
/**
* The post ID
*
* @var int
*/
private $_post_id;
/**
* Sets up an instance if called statically, and attempts to set the featured
* image from an embed in the post content (if one has not already been set).
*
* @param int $post_id
* @return object|null
*/
public function init( $post_id )
{
if ( ! isset( $this ) )
return new ofi( $post_id );
global $wp_embed;
$this->_post_id = absint( $post_id );
if ( ! $this->_thumb_id = get_post_meta( $this->_post_id, '_thumbnail_id', true ) ) {
if ( $content = get_post_field( 'post_content', $this->_post_id, 'raw' ) ) {
add_filter( 'oembed_dataparse', array( $this, 'oembed_dataparse' ), 10, 3 );
$wp_embed->autoembed( $content );
remove_filter( 'oembed_dataparse', array( $this, 'oembed_dataparse' ), 10, 3 );
}
}
}
/**
* @see init()
*/
public function __construct( $post_id )
{
$this->init( $post_id );
}
/**
* Callback for the "oembed_dataparse" hook, which will fire on a successful
* response from the oEmbed provider.
*
* @see WP_oEmbed::data2html()
*
* @param string $return The embed HTML
* @param object $data The oEmbed response
* @param string $url The oEmbed content URL
*/
public function oembed_dataparse( $return, $data, $url )
{
if ( ! empty( $data->thumbnail_url ) && ! $this->_thumb_id ) {
// if ( in_array( @ $data->type, array( 'video' ) ) ) // Only set for video embeds
$this->set_thumb_by_url( $data->thumbnail_url, @ $data->title );
}
}
/**
* Attempt to download the image from the URL, add it to the media library,
* and set as the featured image.
*
* @see media_sideload_image()
*
* @param string $url
* @param string $title Optionally set attachment title
*/
public function set_thumb_by_url( $url, $title = null )
{
/* Following assets will already be loaded if in admin */
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/media.php';
require_once ABSPATH . 'wp-admin/includes/image.php';
$temp = download_url( $url );
if ( ! is_wp_error( $temp ) && $info = @ getimagesize( $temp ) ) {
if ( ! strlen( $title ) )
$title = null;
if ( ! $ext = image_type_to_extension( $info[2] ) )
$ext = '.jpg';
$data = array(
'name' => md5( $url ) . $ext,
'tmp_name' => $temp,
);
$id = media_handle_sideload( $data, $this->_post_id, $title );
if ( ! is_wp_error( $id ) )
return update_post_meta( $this->_post_id, '_thumbnail_id', $this->_thumb_id = $id );
}
if ( ! is_wp_error( $temp ) )
@ unlink( $temp );
}
}
The Earology Dept. - Page 4 of 173 - Where the food sounds good, and the music is pretty tasty too.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
justice | safe and sound
Justice the dynamic Parisian duo of mega iconic dance theory status release their first single in half a decade (that’s 5-years)! The track is titled Safe And Sound courtesy of long time Ed Banger Records. This could be the audible volley over the bow indicating a brand spanking new and forthcoming album release. Here’s hoping. Get the FREE DOWNLOAD. Peace. Continue reading “justice | safe and sound”
Basecamp the Nashville, TN trio that’s been on a tear for a few years now (Watch My Back, Smoke Filled Lungs, Shudder). The band’s latest release the Greater Than EP is six tracks of exactly why we love these guys. The fourth track on the EP Esc gets the remix treatment with Esc (Swindail Remix) and the Esc (josh pan & X&G Remix). I can’t decide which version I like the bestest. Maybe you can help me decide? Peace. Continue reading “basecamp | esc | swindail + josh pan & x&g remixes”
Noel Heroux formerly of the New York rockfit Hooray For Earth, has broken type and reinvented himself, musically and otherwise, as Mass Gothic. The new music is rich, raw and with a low sail it plows the rough seas of the human heart beautifully. His self-titled Sub-Pop release marks a new unencumbered journey and sonically I am all in and loving it. The track Nice Night has a way of both lifting and dampening my spirits and maybe that’s the point. The album Mass Gothic is out now courtesy of Sub Pop Records. Peace. Continue reading “mass gothic | nice night”
Aidan Knight is a modern day bard in the best and most sincere sense of the descriptor. His music is, among other things, robust, genteel and insanely beautiful. The featured track The Arp opens up like a benignly blazing sunrise cresting the far horizon. Song as a scrapbook, the warm sustenance of a hot cup of tea, a meditative playlist and a pocketful of sweetened Gary Snyder poems. Aidan’s latest album Each Other is collectively more profound, for there exists songs here which will become decorous rings around your bleeding heart. Each Other, What Light (Never Goes Dim), You Are Not Here and Black Dream are also notable standouts. Aidan Knight’s album Each Other is out now courtesy of the Outside Music label. Also, take a peek at the Ft. Langley directed video for All Clear video after the jump. Peace. Continue reading “aidan knight | the arp”
miles davis & robert glasper | maiysha (so long) | feat. erykah badu
Not long ago the buzz on the street insinuated that multi-genre maestro Robert Glasper was dropping the tribute album Everything’s Beautiful commemorating the anniversary of the 90th birthday of Jazz icon Miles Davis. And the reveal of some of artist making guest appearances was enough to makes ears the world over salivate:Erykah Badu, KING, Stevie Wonder, Hiatus Kaiyote, Bilal, Phonte, Illa J, and John Scofield, etc. Soon enough Bilal’s feature, Ghetto Walkin’, dropped in conjunction with further details in regard to the album. Continue reading “miles davis & robert glasper | maiysha (so long) | feat. erykah badu”
Hundred Waters does good music. But you know this, so it is not surprising (GASP!) to hear their sonically noble track get abundant blessings with the release of the Show Me Love (Skrillex Remix). We’re talking Mount Everest elevation here, and a higher plane of existence as a result of the deft wonder work of Mr. Sonny J. Moore, Chance The Rapper, Moses Sumney and Robin Hannibal respectively. The original track Show Me Love is one of many (12 actually, but who’s counting? Well, apparently I am) from HW‘s The Moon Rang Like A Bell release courtesy of OWSLA. Peace. Continue reading “hundred waters | show me love | skrillex remix”
Radiohead are sneaky bastards aren’t they? But I suspected something was up when they became a headliner at this year’s Lollapalooza Music Festival. Then after droppin’ a couple of tracks Burn The Witch and Daydreaming every fanboy and fangirl were riven with the possibility of a new full-length release. And now A Moon Shaped Pool is actually a real thing and not some sort of pipe dream. Naturally I am stoked way past 11 and I have already ordered my vinyl! Continue reading “radiohead | a moon shaped pool”
TEEN is a band manned with four future UN ambassadors for the of Island Fun! And while this may (or may not) be entirely a truism it rings as such. Teeny Lieberson and company have spun out (through not fault of their own) yet another wonderfully jollified diversion. The music this band puts out is multi-useful too. Say you’re one to worry about such mundane things as so-in-so liking you or the overdue mortgage. Well, this is the album you most assuredly need to drop the needle on muy pronto! And just so you know this album pairs incredibly well with a pint or two (ice cream or beer, your choice). The album Love Yes is out right this very moment via Carpark Records. Peace. Continue reading “teen | tokyo”
Sorority Noise are solidly east coasters hailing from good old Hartford, Connecticut. And obviously good old Hartford is a pretty good place to stare up an indie rock band. This winsome foursome dedecks their It Kindly Stopped For Me EP with introspective and thoughtful odes to the sour side of living. But it isn’t a bad thing, is it? The rawness and vulnerability of the songs reveal giving fragile hearts and a lovelorn of intimate proportions. Losing someone sucks eggs, but this collection of songs are a bit of catharsis, reached for and obtained, amid a sometimes life of shit. Peace. Continue reading “sorority noise | either way”
Los Angeles-based Swimm (Chris Hess and Adam Winn) release their 6-track Beverly Hells EP via 24 West Records. This isn’t just another tidy release, these are a pocketful of songs of an ebullient vibrancy, and a few all aglow with a lustrous meditative quality (me thinks the tracks All The Time and Suddenly a thoughtful nods to introspection). Good music and a couple of good guys. Psst! My all time favorite Swimm track is Shy, just thought you would like to know. Perfectly perfect! Peace. Continue reading “swimm | beverly hells ep”