當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Board::getAssetUrl方法代碼示例

本文整理匯總了PHP中app\Board::getAssetUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Board::getAssetUrl方法的具體用法?PHP Board::getAssetUrl怎麽用?PHP Board::getAssetUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Board的用法示例。


在下文中一共展示了Board::getAssetUrl方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getThumbnailHTML

 /**
  * Returns an XML valid attachment HTML string that handles missing thumbnail URLs.
  *
  * @param  \App\Board  $board  The board this thumbnail will belong to.
  * @param  int  $maxWidth  Optional. Maximum width constraint. Defaults null.
  * @return string  as HTML
  */
 public function getThumbnailHTML(Board $board, $maxDimension = null)
 {
     $ext = $this->guessExtension();
     $mime = $this->mime;
     $url = media_url("static/img/filetypes/{$ext}.svg", false);
     $spoil = $this->isSpoiler();
     $deleted = $this->isDeleted();
     $md5 = $deleted ? null : $this->hash;
     if ($deleted) {
         $url = $board->getAssetUrl('file_deleted');
     } else {
         if ($spoil) {
             $url = $board->getAssetUrl('file_spoiler');
         } else {
             if ($this->isImageVector()) {
                 $url = $this->getDownloadURL($board);
             } else {
                 if ($this->isAudio() || $this->isImage() || $this->isVideo() || $this->isDocument()) {
                     if ($this->hasThumb()) {
                         $url = $this->getThumbnailURL($board);
                     } else {
                         if ($this->isAudio()) {
                             $url = media_url("static/img/assets/audio.gif", false);
                         }
                     }
                 }
             }
         }
     }
     $classHTML = $this->getThumbnailClasses();
     // Measure dimensions.
     $height = "auto";
     $width = "auto";
     $maxWidth = "none";
     $maxHeight = "none";
     $minWidth = "none";
     $minHeight = "none";
     $oHeight = $this->thumbnail_height;
     $oWidth = $this->thumbnail_width;
     if ($this->has_thumbnail && !$this->isSpoiler() && !$this->isDeleted()) {
         $height = $oHeight . "px";
         $width = $this->thumbnail_width . "px";
         if (is_integer($maxDimension) && ($oWidth > $maxDimension || $oHeight > $maxDimension)) {
             if ($oWidth > $oHeight) {
                 $height = "auto";
                 $width = $maxDimension . "px";
             } else {
                 if ($oWidth < $oHeight) {
                     $height = $maxDimension . "px";
                     $width = "auto";
                 } else {
                     $height = $maxDimension;
                     $width = $maxDimension;
                 }
             }
         }
         $minWidth = $width;
         $minHeight = $height;
     } else {
         $maxWidth = Settings::get('attachmentThumbnailSize') . "px";
         $maxHeight = $maxWidth;
         $width = $maxWidth;
         $height = "auto";
         if (is_integer($maxDimension)) {
             $maxWidth = "{$maxDimension}px";
             $maxHeight = "{$maxDimension}px";
         }
         if ($this->isSpoiler() || $this->isDeleted()) {
             $minHeight = "none";
             $minWidth = "none";
             $width = $maxWidth;
         }
     }
     return "<div class=\"attachment-wrapper\" style=\"height: {$height}; width: {$width};\">" . "<img class=\"attachment-img {$classHTML}\" src=\"{$url}\" data-mime=\"{$mime}\" data-md5=\"{$md5}\" style=\"height: {$height}; width: {$width};\"/>" . "</div>";
 }
開發者ID:tmrwbo,項目名稱:infinity-next,代碼行數:82,代碼來源:FileStorage.php

示例2: getThumbnailHTML

 /**
  * Returns an XML valid attachment HTML string that handles missing thumbnail URLs.
  *
  * @return string as HTML
  */
 public function getThumbnailHTML(Board $board)
 {
     $ext = $this->guessExtension();
     $mime = $this->mime;
     $url = asset("static/img/filetypes/{$ext}.svg");
     $type = "other";
     $html = "";
     $stock = true;
     $spoil = $this->isSpoiler();
     if ($spoil) {
         $url = $board->getAssetUrl('file_spoiler');
     } else {
         if ($this->isVideo()) {
             if ($this->hasThumb()) {
                 $stock = false;
                 $url = $this->getThumbnailURL($board);
                 $type = "video";
             }
         } else {
             if ($this->isAudio()) {
                 $stock = false;
                 $type = "audio";
                 $url = $this->getThumbnailURL($board);
             } else {
                 if ($this->isImage()) {
                     if ($this->hasThumb()) {
                         $stock = false;
                         $url = $this->getThumbnailURL($board);
                         $type = "img";
                     }
                 } else {
                     if ($this->isImageVector()) {
                         $stock = false;
                         $url = $this->getDownloadURL($board);
                         $type = "img";
                     }
                 }
             }
         }
     }
     $classes = [];
     $classes['type'] = "attachment-type-{$type}";
     $classes['ext'] = "attachent-ext-{$ext}";
     $classes['stock'] = $stock ? "thumbnail-stock" : "thumbnail-content";
     $classes['spoil'] = $spoil ? "thumbnail-spoiler" : "thumbnail-not-spoiler";
     $classHTML = implode(" ", $classes);
     return "<div class=\"attachment-wrapper {$classHTML}\"><img class=\"attachment-img {$classHTML}\" src=\"{$url}\" data-mime=\"{$mime}\" /></div>";
 }
開發者ID:JEWSbreaking8chan,項目名稱:infinity-next,代碼行數:53,代碼來源:FileStorage.php

示例3: getThumbnailHTML

 /**
  * Returns an XML valid attachment HTML string that handles missing thumbnail URLs.
  *
  * @return string  as HTML
  */
 public function getThumbnailHTML(Board $board)
 {
     $ext = $this->guessExtension();
     $mime = $this->mime;
     $url = asset("static/img/filetypes/{$ext}.svg");
     $spoil = $this->isSpoiler();
     if ($spoil) {
         $url = $board->getAssetUrl('file_spoiler');
     } else {
         if ($this->isImageVector()) {
             $url = $this->getDownloadURL($board);
         } else {
             if ($this->isAudio() || $this->isImage() || $this->isVideo()) {
                 if ($this->hasThumb()) {
                     $url = $this->getThumbnailURL($board);
                 } else {
                     if ($this->isAudio()) {
                         $url = asset("static/img/assets/audio.gif");
                     }
                 }
             }
         }
     }
     $classHTML = $this->getThumbnailClasses();
     // Measure dimensions.
     $height = "auto";
     $width = "auto";
     if ($this->has_thumbnail) {
         $oHeight = $this->thumbnail_width;
         $oWidth = $this->thumbnailWidth;
         if ($this->thumbnail_width > $this->thumbnail_height) {
             $width = $this->thumbnail_width . "px";
         } else {
             if ($this->thumbnail_width < $this->thumbnail_height) {
                 $height = $this->thumbnail_height . "px";
             }
         }
     } else {
         $oHeight = Settings::get('attachmentThumbnailSize') . "px";
         $oWidth = $oHeight;
         $width = $oHeight;
         $height = $oHeight;
     }
     return "<div class=\"attachment-wrapper\" style=\"height: {$oHeight}; width: {$oWidth};\">" . "<img class=\"attachment-img {$classHTML}\" src=\"{$url}\" data-mime=\"{$mime}\" style=\"height: {$height}; width: {$width};\"/>" . "</div>";
 }
開發者ID:GodOfConquest,項目名稱:infinity-next,代碼行數:50,代碼來源:FileStorage.php


注:本文中的app\Board::getAssetUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。