}
function transform( $params, $flags = 0 ) {
- if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
+ if ( $this->repo->canCacheThumbs() ) {
$thumbUrl = $this->repo->getThumbUrlFromCache(
$this->getName(),
isset( $params['width'] ) ? $params['width'] : -1,
*/
function getThumbPath( $suffix = '' ) {
$ret = null;
- if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) {
+ if ( $this->repo->canCacheThumbs() ) {
global $wgUploadDirectory;
$path = $wgUploadDirectory . '/' . $this->repo->apiThumbCacheDir . '/' . $this->repo->name . '/';
if ( $suffix ) {
function getThumbUrlFromCache( $name, $width, $height ) {
global $wgMemc, $wgUploadPath, $wgServer, $wgUploadDirectory;
-;
$key = wfMemcKey( 'ForeignAPIRepo', 'ThumbUrl', $name );
if ( $thumbUrl = $wgMemc->get($key) ) {
return $localUrl;
}
}
+
+ /**
+ * Are we locally caching the thumbnails?
+ * @return bool
+ */
+ public function canCacheThumbs() {
+ return ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir );
+ }
}