/** * Returns the size of an image. * * @param string $url The URL of the image * @return array|false Returns an array with width and height of the image or FALSE on error. */ protected function getImageSize($url) { $request = $this->http->get($url, ['Range' => 'bytes=0-32768']); if (!$request->success) { return false; } return getimagesizefromstring($request->data); }
/** * Queries the oEmbed endpoint of the provider. * * @param string $endpoint The endpoint URL * @param string $url The content URL, set to NULL if the endpoint URL already contains this parameter * @param string $format The request format, set to NULL if the endpoint URL already contains this parameter * @param array $args An array of optional extra arguments * @return string Returns the raw request data. */ public function queryProvider($endpoint, $url = null, $format = 'json', array $args = []) { if ($url !== null) { if ($format === null) { throw new \InvalidArgumentException('The request format must be defined in manual mode.'); } $args['url'] = (string) $url; $args['format'] = (string) $format; $concat = '?'; } else { $concat = parse_url($endpoint, PHP_URL_QUERY) != '' ? '&' : '?'; } $query = http_build_query(array_replace($this->args, $args)); return $this->http->get($endpoint . $concat . $query); }