From: Marcel Werk Date: Wed, 30 Nov 2016 16:18:53 +0000 (+0100) Subject: Fixed multiple issues caused by missing media thumbnails X-Git-Tag: 3.0.0_RC_1~107 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f4d9e975fc0992769991e237b39904c6e7d62d68;p=GitHub%2FWoltLab%2FWCF.git Fixed multiple issues caused by missing media thumbnails --- diff --git a/com.woltlab.wcf/templates/article.tpl b/com.woltlab.wcf/templates/article.tpl index 1ee8b7d21b..b3879d46f0 100644 --- a/com.woltlab.wcf/templates/article.tpl +++ b/com.woltlab.wcf/templates/article.tpl @@ -98,7 +98,7 @@ {include file='header'} -{if $articleContent->getImage()} +{if $articleContent->getImage() && $articleContent->getImage()->hasThumbnail('large')}
{@$articleContent->getImage()->getThumbnailTag('large')}
@@ -252,7 +252,7 @@ {foreach from=$relatedArticles item='relatedArticle'}
  • - {if $relatedArticle->getImage()} + {if $relatedArticle->getImage() && $relatedArticle->getImage()->hasThumbnail('tiny')}
    {@$relatedArticle->getImage()->getThumbnailTag('tiny')}
    {/if} @@ -285,8 +285,8 @@ {@$relatedArticle->getFormattedTeaser()}
    - - {if $relatedArticle->getImage()} + + {if $relatedArticle->getImage() && $relatedArticle->getImage()->hasThumbnail('tiny')} {/if}
    diff --git a/com.woltlab.wcf/templates/articleListItems.tpl b/com.woltlab.wcf/templates/articleListItems.tpl index 242e623770..8c5cd741b4 100644 --- a/com.woltlab.wcf/templates/articleListItems.tpl +++ b/com.woltlab.wcf/templates/articleListItems.tpl @@ -2,7 +2,7 @@ {foreach from=$objects item='article'}
  • - {if $article->getImage()} + {if $article->getImage() && $article->getImage()->hasThumbnail('tiny')}
    {@$article->getImage()->getThumbnailTag('tiny')}
    {/if} @@ -37,8 +37,8 @@ {@$article->getFormattedTeaser()}
    - - {if $article->getImage()} + + {if $article->getImage() && $article->getImage()->hasThumbnail('tiny')} {/if}
    diff --git a/com.woltlab.wcf/templates/boxArticleList.tpl b/com.woltlab.wcf/templates/boxArticleList.tpl index 23c6494a08..3dfc32ca1c 100644 --- a/com.woltlab.wcf/templates/boxArticleList.tpl +++ b/com.woltlab.wcf/templates/boxArticleList.tpl @@ -32,7 +32,7 @@ {foreach from=$boxArticleList item=boxArticle}
  • - {if $boxArticle->getImage()} + {if $boxArticle->getImage() && $boxArticle->getImage()->hasThumbnail('small')}
    {@$boxArticle->getImage()->getThumbnailTag('small')}
    {/if} diff --git a/com.woltlab.wcf/templates/mediaEditor.tpl b/com.woltlab.wcf/templates/mediaEditor.tpl index 65f0fe0813..08a73a573f 100644 --- a/com.woltlab.wcf/templates/mediaEditor.tpl +++ b/com.woltlab.wcf/templates/mediaEditor.tpl @@ -1,4 +1,4 @@ -{if $media->isImage} +{if $media->isImage && $media->hasThumbnail('small')}
    {@$media->getThumbnailTag('small')}
    diff --git a/wcfsetup/install/files/acp/templates/articleAdd.tpl b/wcfsetup/install/files/acp/templates/articleAdd.tpl index c79ecbaf9a..3c308ac39e 100644 --- a/wcfsetup/install/files/acp/templates/articleAdd.tpl +++ b/wcfsetup/install/files/acp/templates/articleAdd.tpl @@ -158,7 +158,7 @@
    - {if $images[0]|isset} + {if $images[0]|isset && $images[0]->hasThumbnail('small')} {@$images[0]->getThumbnailTag('small')} {/if}
    @@ -169,7 +169,7 @@ {/if}
    - {elseif $action == 'edit' && $images[0]|isset} + {elseif $action == 'edit' && $images[0]|isset && $images[0]->hasThumbnail('small')}
    {lang}wcf.acp.article.image{/lang}
    @@ -272,7 +272,7 @@
    - {if $images[$availableLanguage->languageID]|isset} + {if $images[$availableLanguage->languageID]|isset && $images[$availableLanguage->languageID]->hasThumbnail('small')} {@$images[$availableLanguage->languageID]->getThumbnailTag('small')} {/if}
    @@ -283,7 +283,7 @@ {/if}
    - {elseif $action == 'edit' && $images[$availableLanguage->languageID]|isset} + {elseif $action == 'edit' && $images[$availableLanguage->languageID]|isset && $images[$availableLanguage->languageID]->hasThumbnail('small')}
    {lang}wcf.acp.article.image{/lang}
    diff --git a/wcfsetup/install/files/acp/templates/boxAdd.tpl b/wcfsetup/install/files/acp/templates/boxAdd.tpl index 493234589c..5cca3ea98f 100644 --- a/wcfsetup/install/files/acp/templates/boxAdd.tpl +++ b/wcfsetup/install/files/acp/templates/boxAdd.tpl @@ -256,7 +256,7 @@
    - {if $images[0]|isset} + {if $images[0]|isset && $images[0]->hasThumbnail('small')} {@$images[0]->getThumbnailTag('small')} {/if}
    @@ -267,7 +267,7 @@ {/if}
    - {elseif $action == 'edit' && $images[0]|isset} + {elseif $action == 'edit' && $images[0]|isset && $images[0]->hasThumbnail('small')}
    {lang}wcf.acp.box.image{/lang}
    @@ -329,7 +329,7 @@
    - {if $images[$availableLanguage->languageID]|isset} + {if $images[$availableLanguage->languageID]|isset && $images[$availableLanguage->languageID]->hasThumbnail('small')} {@$images[$availableLanguage->languageID]->getThumbnailTag('small')} {/if}
    @@ -340,7 +340,7 @@ {/if}
    - {elseif $action == 'edit' && $images[$availableLanguage->languageID]|isset} + {elseif $action == 'edit' && $images[$availableLanguage->languageID]|isset && $images[$availableLanguage->languageID]->hasThumbnail('small')}
    {lang}wcf.acp.box.image{/lang}
    diff --git a/wcfsetup/install/files/acp/templates/mediaEditor.tpl b/wcfsetup/install/files/acp/templates/mediaEditor.tpl index 576bb515e8..dfe759a1e9 100644 --- a/wcfsetup/install/files/acp/templates/mediaEditor.tpl +++ b/wcfsetup/install/files/acp/templates/mediaEditor.tpl @@ -1,4 +1,4 @@ -{if $media->isImage} +{if $media->isImage && $media->hasThumbnail('small')}
    {@$media->getThumbnailTag('small')}
    diff --git a/wcfsetup/install/files/lib/data/media/Media.class.php b/wcfsetup/install/files/lib/data/media/Media.class.php index 819440a7dc..e1ff1b1b97 100644 --- a/wcfsetup/install/files/lib/data/media/Media.class.php +++ b/wcfsetup/install/files/lib/data/media/Media.class.php @@ -207,6 +207,29 @@ class Media extends DatabaseObject implements ILinkableObject, IRouteController, return WCF::getSession()->getPermission('admin.content.cms.canManageMedia') || SimpleAclResolver::getInstance()->canAccess('com.woltlab.wcf.media', $this->mediaID); } + /** + * Returns true if a thumbnail version with the given size is available. + * + * @param string $size + * @return boolean + * @throws \InvalidArgumentException + */ + public function hasThumbnail($size) { + if (!isset(self::$thumbnailSizes[$size])) { + throw new \InvalidArgumentException("Unknown thumbnail size '".$size."'"); + } + + if ($this->{$size.'ThumbnailType'}) { + return true; + } + + if ($this->width <= self::$thumbnailSizes[$size]['width'] && $this->height <= self::$thumbnailSizes[$size]['height']) { + return true; + } + + return false; + } + /** * Returns the storage path of the media files. *