/** * Get first image from slider from selected hub v3 * * @param $cityId hub wiki id * @return null|string */ public function getHubV3Images($cityId) { $imageUrl = null; $destSize = $this->getHubsImgWidth() . 'x' . $this->getHubsImgHeight(); $sliderData = $this->getHubSliderData(['city' => $cityId]); if (isset($sliderData['data']['slides'][0]['photoName'])) { $imgName = $sliderData['data']['slides'][0]['photoName']; $title = GlobalTitle::newFromText($imgName, NS_FILE, $cityId); if ($title !== null) { $file = new GlobalFile($title); if ($file !== null) { $imageUrl = ImagesService::getThumbUrlFromFileUrl($file->getUrl(), $destSize); } } } return $imageUrl; }
/** * @desc returns URL to the cropped thumb of an image * * @param String $url - image url * @param Integer $width desired width of a thumbnail * @param Integer $height desired height of a thumbnail * @param String $align - crop align (origin || center) * * @return String - thumbnail URL */ public function createCroppedThumb($url, $width, $height, $align = self::THUMB_ALIGNMENT_CENTER) { $breakPoint = strrpos($url, '/'); $baseURL = substr($url, 0, $breakPoint); $fileName = substr($url, $breakPoint + 1); $deltaY = $align === self::THUMB_ALIGNMENT_CENTER ? self::DELTA_Y_CENTERED : self::DELTA_Y_DEFAULT; return ImagesService::getThumbUrlFromFileUrl($baseURL . self::MAP_THUMB_PREFIX . $fileName, $width . 'x' . $height . 'x' . $deltaY); }
/** * method for taking scaled avatars * - avatar will be scaled by external image thumbnailer * - external image thumbnailer use only width and scale it with the same * proportion as original * - currently there's no thumbnail file, it's only cached on varnish and * generated on fly as needed * * @access public * @author Krzysztof Krzyżaniak (eloy) * * @param width - the width of the thumbnail (height will be same propotion to width as in unscaled image) * @param inPurgeFormat - boolean - if true, then the returned URL will be in the format used for purging * which means it will use images.wikia.com instead of a CDN hostname. * * * @return string -- url to Avatar */ public function getThumbnail($width, $inPurgeFormat = false) { if ($inPurgeFormat) { $url = $this->getPurgeUrl('/thumb/'); } else { $url = $this->getUrl('/thumb/'); } return ImagesService::getThumbUrlFromFileUrl($url, $width); }
/** * @dataProvider getThumbUrlFromFileUrlDataProvider */ public function testGetThumbUrlFromFileUrl($imageUrl, $destSize, $newExtension, $expected) { $this->assertEquals($expected, ImagesService::getThumbUrlFromFileUrl($imageUrl, $destSize, $newExtension)); }