/** * {@inheritdoc} */ public function getHeight() { if (!parent::getCode()) { return 425; } return parent::getHeight(); }
/** * {@inheritdoc} */ public function run() { if ($this->request->match('*/maps/*')) { $this->addProvider('google', new Api\GoogleMaps()); } parent::run(); }
/** * {@inheritdoc} */ public function run() { if ($this->request->getHttpCode() === 429) { $this->addProvider('oembed', new Providers\OEmbed()); return; } parent::run(); }
/** * {@inheritdoc} */ public function run() { parent::run(); $this->api = new Bag(); $api = $this->request->createRequest($this->request->url->getUrl() . '.json'); if ($json = $api->getJsonContent()) { $this->api->set($json); } }
/** * {@inheritdoc} */ public function getCode() { if ($this->request->match('https://github.com/*/*/blob/*')) { $username = $this->request->getDirectoryPosition(0); $repo = $this->request->getDirectoryPosition(1); $ref = $this->request->getDirectoryPosition(3); $path_to_file = implode('/', $this->request->getSlicePath(4)); switch ($this->request->getExtension()) { case 'geojson': //https://help.github.com/articles/mapping-geojson-files-on-github/#embedding-your-map-elsewhere return "<script src=\"https://embed.githubusercontent.com/view/geojson/{$username}/{$repo}/{$ref}/{$path_to_file}\"></script>"; case 'stl': //https://help.github.com/articles/3d-file-viewer/#embedding-your-model-elsewhere return "<script src=\"https://embed.githubusercontent.com/view/3d/{$username}/{$repo}/{$ref}/{$path_to_file}\"></script>"; } } return parent::getCode(); }
/** * {@inheritdoc} */ public function getImagesUrls() { $images = parent::getImagesUrls(); $apiImages = $this->api->get('images'); if (isset($apiImages['query']['pages'])) { $page = current($apiImages['query']['pages']); $imgs = []; foreach ($page['images'] as $image) { switch (strrchr($image['title'], '.')) { case '.png': case '.jpg': case '.gif': case '.jpeg': $imgs[] = $image['title']; break; } } //Get image urls if ($imgs) { $url = clone $this->request->url; $url->setPath('/w/api.php'); $url->setParameter('action', 'query'); $url->setParameter('prop', 'imageinfo'); $url->setParameter('iiprop', 'url'); $url->setParameter('format', 'json'); $url->setParameter('continue', ''); $url->setParameter('titles', implode('|', $imgs)); $json = $this->request->createRequest($url)->getJsonContent(); if (isset($json['query']['pages'])) { foreach ($json['query']['pages'] as $page) { if (isset($page['imageinfo'][0]['url'])) { Utils::unshiftValue($images, ['value' => $page['imageinfo'][0]['url'], 'providers' => ['api']]); } } } } } return $images; }
/** * {@inheritdoc} */ public function run() { $this->addProvider('soundcloud', new Api\Soundcloud()); parent::run(); }
/** * {@inheritdoc} */ public function run() { $this->addProvider('archive', new Api\Archive()); parent::run(); }
/** * {@inheritdoc} */ protected function run() { $this->addProvider('wikipedia', new Api\Wikipedia()); parent::run(); }
/** * {@inheritdoc} */ public function getImagesUrls() { $images = parent::getImagesUrls(); if ($url = $this->api->get('misc', 'image')) { Utils::unshiftValue($images, ['value' => $this->request->url->getAbsolute($url), 'providers' => ['api']]); } if (is_array($files = $this->api->get('files'))) { foreach ($files as $url => $info) { Utils::unshiftValue($images, ['value' => $this->request->url->getAbsolute($url), 'providers' => ['api']]); } } return $images; }
/** * {@inheritdoc} */ public function run() { $this->addProvider('facebook', new Api\Facebook()); parent::run(); }
/** * {@inheritdoc} */ public function run() { $this->addProvider('imageshack', new Api\Imageshack()); parent::run(); }
/** * {@inheritdoc} */ public function getAuthorUrl() { return $this->api->get('user', 'permalink_url') ?: parent::getAuthorUrl(); }
/** * {@inheritdoc} */ public function getImagesUrls() { $images = parent::getImagesUrls(); if (($cover = $this->api->get('cover')) && !empty($cover['source'])) { Utils::unshiftValue($images, ['value' => $cover['source'], 'providers' => ['api']]); } if ($id = $this->api->get('id')) { Utils::unshiftValue($images, ['value' => 'https://graph.facebook.com/' . $id . '/picture', 'providers' => ['api']]); } return $images; }