class MediaFlickrStreamWrapper in Media: Flickr 7
Same name in this branch
- 7 MediaFlickrStreamWrapper.inc \MediaFlickrStreamWrapper
- 7 includes/MediaFlickrStreamWrapper.inc \MediaFlickrStreamWrapper
Same name and namespace in other branches
- 7.2 includes/MediaFlickrStreamWrapper.inc \MediaFlickrStreamWrapper
Create an instance like this: $flickr = new MediaFlickrStreamWrapper('flickr://u/[user-code]/p/[photo-code]');
Hierarchy
- class \MediaFlickrStreamWrapper extends \MediaReadOnlyStreamWrapper
Expanded class hierarchy of MediaFlickrStreamWrapper
1 string reference to 'MediaFlickrStreamWrapper'
- media_flickr_stream_wrappers in ./
media_flickr.module - Create stream wrapper for Flickr videos.
File
- includes/
MediaFlickrStreamWrapper.inc, line 12 - Create a Flickr Stream Wrapper class for the Media/Resource module.
View source
class MediaFlickrStreamWrapper extends MediaReadOnlyStreamWrapper {
protected $base_url = 'https://www.flickr.com/';
protected $parameters = array(
'u' => NULL,
'p' => NULL,
's' => NULL,
'search' => NULL,
);
public function interpolateUrl() {
if (isset($this->parameters['u']) && isset($this->parameters['p'])) {
return $this->base_url . 'photos/' . check_plain($this->parameters['u']) . '/' . check_plain($this->parameters['p']);
}
if (isset($this->parameters['u']) && isset($this->parameters['s'])) {
if ($this->parameters['s'] == 'photoset') {
return $this->base_url . 'photos/' . check_plain($this->parameters['u']);
}
return $this->base_url . 'photos/' . check_plain($this->parameters['u']) . '/sets/' . check_plain($this->parameters['s']);
}
if (isset($this->parameters['search'])) {
return $this->base_url . 'search/?q=' . check_plain($this->parameters['search']);
}
}
public function getTarget($f) {
return FALSE;
}
/**
* Get the url of the original image.
*/
public function getExternalUrl() {
// Look for Photosets & searches.
if (!isset($this->parameters['p'])) {
if (isset($this->parameters['search']) || isset($this->parameters['s']) && $this->parameters['s']) {
return media_flickr_image_url(media_flickr_photoset_photo_id($this->uri));
}
// Don't fall through.
return;
}
// Return the direct image.
$url = media_flickr_image_url($this->parameters['p']);
return $url;
}
public function getOriginalThumbnailPath() {
return $this
->getExternalUrl();
}
public function getLocalThumbnailPath() {
$parts = $this
->get_parameters();
$local_path = str_replace('flickr://', 'public://media-flickr/', check_plain($this->uri)) . '.jpg';
if (!file_exists($local_path)) {
$dirname = drupal_dirname($local_path);
file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
@copy($this
->getOriginalThumbnailPath(), $local_path);
}
return $local_path;
}
public static function getMimeType($uri, $mapping = NULL) {
if (strpos($uri, '/s/') !== FALSE) {
return 'video/flickr';
}
elseif (strpos($uri, '//search/') !== FALSE) {
return 'video/flickr';
}
return 'image/jpeg';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MediaFlickrStreamWrapper:: |
protected | property | ||
MediaFlickrStreamWrapper:: |
protected | property | ||
MediaFlickrStreamWrapper:: |
public | function | Get the url of the original image. | |
MediaFlickrStreamWrapper:: |
public | function | ||
MediaFlickrStreamWrapper:: |
public static | function | ||
MediaFlickrStreamWrapper:: |
public | function | ||
MediaFlickrStreamWrapper:: |
public | function | ||
MediaFlickrStreamWrapper:: |
public | function |