Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Automatically embed Dribbble shots into WordPress content
Plugin Name: Dribbble Shot Embed
Description: Automatically embed a shot into your WordPress site just by dropping the URL in place.
Version: 1.0.0.RC.1
Author: Nick Ohrn of
Author URI:
function dribbble_shot_embed_callback($matches, $attr, $url, $rawattr) {
$output = false;
if(($id = isset($matches[1]) ? $matches[1] : false)) {
$key = sprintf('dribbble_shot_%d', $id);
$shot = get_transient($key);
if(false === $shot) {
$response = wp_remote_get(sprintf('', $id));
if(!is_wp_error($response)) {
$shot = json_decode(wp_remote_retrieve_body($response), true);
if($shot) {
set_transient($key, $shot, DAY_IN_SECONDS);
if($shot) {
$title = esc_attr($shot['title']);
$url = esc_attr(esc_url($shot['url']));
$image_height = absint($shot['height']);
$image_src = esc_attr(esc_url($shot['image_url']));
$image_width = absint($shot['width']);
$output = sprintf('<a href="%1$s" target="_blank" title="%2$s"><img alt="%2$s" src="%3$s" height="%4$d" width="%5$d" /></a>', $url, $title, $image_src, $image_height, $image_width);
return $output;
function dribbble_shot_embed_wp_embed_register_handler() {
wp_embed_register_handler('dribbble-shot-embed', '#^\d+)#i', 'dribbble_shot_embed_callback');
add_action('init', 'dribbble_shot_embed_wp_embed_register_handler');

This comment has been minimized.

Copy link
Owner Author

@nickohrn nickohrn commented Mar 11, 2014

This is super rough and something I threw together as a proof of concept more than anything. If you're interested, please let me know and I can turn this into something a little more robust :)


This comment has been minimized.

Copy link

@RomanSima RomanSima commented Nov 15, 2015

Doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.