/*
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 10 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!
lilies on mars | dancing star
lilies on mars | dancing star
Lilies On Mars (Lisa Masia and Marina Cristofalo) are electronic psychedelico done up in gossamer rags of such make and model you’d swear this is an ethereal and heavenly intervention. Listening to Dancing Star makes me feel clean and new again without the Hail Marys and Our Fathers. Who knew? If you like this (and you will certainly like this) make sure to check out the full album, the new release ∆GO is out now courtesy of Lady Sometimes Records. Peace. Continue reading “lilies on mars | dancing star”
London-based Nao is winning and we’re all the better for it. With vocals clear as the scrubbed air after a lightning strike she delivers the latest offing Bad Blood with uncanny virtuosity. Consider our appetites sufficiently whetted. Here’s looking to her soon-to-blow-our-minds debut and if it doesn’t drop soon somebodies gonna get hurt. Peace. Continue reading “nao | bad blood”
Canadian rockers Greek Riots splits your melon open to the white meat and gives your exposed grey matter it’s monies worth in air conditioning. C’mon that’s a great metaphor. I worked on it all day. Metaphors aside these guys know how to bring it. So if your in the mood for a kick is the pants, well this will do ya’ mighty fine.
The band’s latest album Middle Children is half a dozen spit-shined tracks with enough adrenaline to fuel your most ambitious excursions into funland. My pick of the litter is the track How Far just because it’s kinda melancholy but still kick ass enough to chase away the doldrums. The mini-ablum Middle Children is out now. Peace and chicken grease. Continue reading “greek riots | middle children”
If you ever deign to turn over the underside of darkness you may just find somethings are not always what they appear to be. Los Angeles burgher and electronic musician/producer Adam Finkel aka Alex Fin is adept at showcasing the light of the sun in mendicant stripes. The track Golden, Blinding featuring Galun is a sound shard of delight as it sashays robustly upon a phosphorescent stage. This is music which can teleport listeners towards untold realms of beauty. Continue reading “alex fin | golden, blinding | feat. galun”
The Washington D.C.-based duo GEMS (Lindsay Pitts and Clifford John Usher) will upend you. And, as your tumbling head over heels you’ll hear the glorious rhapsody of overspilt odes from their debut offering Kill The One You Love. The songs here are as gossamer as tendriled light refracted through crystallized synapses. Yup, just like that I promise.
If your not a fan now is as good a time as any to get a headful of GEMS. My favorite track from the lot is Tangled Memories or maybe I am just enthralled with Lindsay’s piquant vocals. I am thinking it’s both. The album Kill The One You Love is out now courtesy of Carpark Records. Ordering deets after the jump. Peace. Continue reading “gems | kill the one you love”
Beach House is one of my favorite bands and with good reason. Here is a band whose music can instantly slow the spin of the entire earth as soon as I click play. If you’re a fan you already know. The band’s new album Thank Your Lucky Stars dropped recently and it’s a beautiful thing. After the jump listen to the full album stream. Peace. Continue reading “beach house | thank your lucky stars”
Futurekids always keep things interesting and fresh picked. I also lovingly appreciate the chill vibe the band emit through low-key sound miracles and surprisingly sentimental ditties. Case in point, the premiere of White Girl In A Wu Tang Shirt offers the quaint and lovey dovey. This track smolders like the embers of a nostalgic campfire ricocheting inside the synapses of fond memory. And although my assertions fall infinitely short of adequate fluffery you’ll appreciate the point.
This is good music plain and simple. The bands forthcoming album This Is Everything drops November 21st 2015. Below you can also check out the short Making of This Is Everything after the jump and get the FREE DOWNLOAD for a limited time, because don’t cha know a good thing doesn’t last forever. Peace. Continue reading “futurekids | white girl in a wu tang shirt”
Neon Indian (Alan Paloma) drops his third album VEGA INTL. Night School and it reeks of badassery! Even though it’s been a lil’ minute since we last heard new material (2011 to be exact, but who’s counting?) from The Fluorescent One, but all is forgiven. We’ve heard the tracks Annie and Slumlord (with the latter being my fav fav favorite) but I am majorly and overyly excited to hear the other 12 tracks. The VEGA INTL. Night School album hits streets today courtesy of Mom + Pop Records. Psst! After the jump you can listen to the full album stream by clicking on the fabulous NPR Music Player. Peace. Continue reading “neon indian | vega intl. night school”
The band Hinds otherwise known as las chicas de Madrid just released their debut album Leave Me Alone. This is no mean feat, because well… it just is, trust me on this one. In my head there are few things as exciting as a girl band that knows how to rock like there’s no tomorrow. After the jump check out the single Garden it’ll make you smile. Peace. Continue reading “hinds | garden”
Big Black Delta recently reached out to the unforgettable and all around 80’s pop legend Debbie Gibson and the results are definitely cool in any era. The track RCVR has a retro feel with it’s wavy gravy synths, pronounced bass licks and staccato drums. And my ears are happy to report the D to the G sounds as good as ever. Continue reading “rcvr | featuring debbie gibson”