function getImageSource() { if (isset($this->canonicalTweet->entities->media[0]->media_url)) { $this->image = $this->canonicalTweet->entities->media[0]->media_url; // check dimensions $FastImageSize = new \FastImageSize\FastImageSize(); $imageSize = $FastImageSize->getImageSize($this->image); $this->image_height = $imageSize['height']; $this->image_width = $imageSize['width']; return $this->image; } }
function getImageSource() { $this->image = $this->rawPost->images->low_resolution->url; if ($this->image) { //have image, check dimensions $FastImageSize = new \FastImageSize\FastImageSize(); $imageSize = $FastImageSize->getImageSize($this->image); $this->image_height = $imageSize['height']; $this->image_width = $imageSize['width']; } return $this->image; }
/** * Parse img tag */ function bbcode_img($in) { global $user, $config; if (!$this->check_bbcode('img', $in)) { return $in; } $in = trim($in); $error = false; $in = str_replace(' ', '%20', $in); // Checking urls if (!preg_match('#^' . get_preg_expression('url') . '$#iu', $in) && !preg_match('#^' . get_preg_expression('www_url') . '$#iu', $in)) { return '[img]' . $in . '[/img]'; } // Try to cope with a common user error... not specifying a protocol but only a subdomain if (!preg_match('#^[a-z0-9]+://#i', $in)) { $in = 'http://' . $in; } if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) { $imagesize = new \FastImageSize\FastImageSize(); $size_info = $imagesize->getImageSize(htmlspecialchars_decode($in)); if ($size_info === false) { $error = true; $this->warn_msg[] = $user->lang['UNABLE_GET_IMAGE_SIZE']; } else { if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $size_info['height']) { $error = true; $this->warn_msg[] = $user->lang('MAX_IMG_HEIGHT_EXCEEDED', (int) $config['max_' . $this->mode . '_img_height']); } if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $size_info['width']) { $error = true; $this->warn_msg[] = $user->lang('MAX_IMG_WIDTH_EXCEEDED', (int) $config['max_' . $this->mode . '_img_width']); } } } if ($error || $this->path_in_domain($in)) { return '[img]' . $in . '[/img]'; } return '[img:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($in) . '[/img:' . $this->bbcode_uid . ']'; }
/** * Filter an image's URL to enforce restrictions on its dimensions * * @see bbcode_firstpass::bbcode_img() * * @param string $url Original URL * @param array $url_config Config used by the URL filter * @param Logger $logger * @param integer $max_height Maximum height allowed * @param integer $max_width Maximum width allowed * @return string|bool Original value if valid, FALSE otherwise */ public static function filter_img_url($url, array $url_config, Logger $logger, $max_height, $max_width) { // Validate the URL $url = BuiltInFilters::filterUrl($url, $url_config, $logger); if ($url === false) { return false; } if ($max_height || $max_width) { $imagesize = new \FastImageSize\FastImageSize(); $size_info = $imagesize->getImageSize($url); if ($size_info === false) { $logger->err('UNABLE_GET_IMAGE_SIZE'); return false; } if ($max_height && $max_height < $size_info['height']) { $logger->err('MAX_IMG_HEIGHT_EXCEEDED', array('max_height' => $max_height)); return false; } if ($max_width && $max_width < $size_info['width']) { $logger->err('MAX_IMG_WIDTH_EXCEEDED', array('max_width' => $max_width)); return false; } } return $url; }