From: Cyperghost Date: Tue, 12 Nov 2024 13:51:32 +0000 (+0100) Subject: Added documentation for the Image Viewer(FancyBox) X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=689c6f57d220b99b04e5b5b6e86140a1e84cb572;p=GitHub%2FWoltLab%2Fwoltlab.github.io.git Added documentation for the Image Viewer(FancyBox) --- diff --git a/docs/javascript/components_image_viewer.md b/docs/javascript/components_image_viewer.md new file mode 100644 index 00000000..4f30e722 --- /dev/null +++ b/docs/javascript/components_image_viewer.md @@ -0,0 +1,109 @@ +# Image Viewer + +The Image Viewer component enables interactive image viewing in a modal, using the [Fancybox](https://fancyapps.com/fancybox/) library. +It supports automatic or manual opening and grouping of images. + +Not only images, but also Videos, YouTube Videos, PDFs, HTML, [...](https://fancyapps.com/fancybox/) are supported and can be displayed in the modal. +The appropriate `data-type` must be set, the system tries to determine this if it has not been set. +For example, the following can be used: + +- `image` - Image +- `pdf` - PDF file +- `html5video` - HTML5 video +- `youtube` - YouTube video +- `vimeo` - Vimeo video + +## Open Image Viewer Automatically + +The following code example adds an image to the global modal and groups it with all other images that are not explicitly grouped: + +```smarty + + + +``` + +If you want to display several images in a group, you can group them using the `data-fancybox` attribute. Images with the same group name are then displayed together: + +```smarty + + + +``` + +## Grouping content from the same message + +To ensure that images are only grouped from the same message in the same modal, `data-fancybox="message-{$messageObjectType}-{$messageObjectID}"` is used in the BBCode. + +```php +final class FooBBCode extends AbstractBBCode +{ + #[\Override] + public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser): string + { + $objectID = (!empty($openingTag['attributes'][0])) ? \intval($openingTag['attributes'][0]) : 0; + if (!$objectID) { + return ''; + } + + $foo = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.foo', $objectID); + if ($foo === null) { + return ContentNotVisibleView::forNotAvailable(); + } + + if (!$foo->isAccessible()) { + return ContentNotVisibleView::forNoPermission(); + } + + if ($parser->getOutputType() == 'text/html') { + return WCF::getTPL()->fetch('shared_bbcode_foo', 'wcf', [ + 'imageLink' => $foo->getLink(), + 'caption' => $foo->getTitle(), + 'activeMessageID' => MessageEmbeddedObjectManager::getInstance()->getActiveMessageID(), + 'activeMessageObjectType' => MessageEmbeddedObjectManager::getInstance()->getActiveMessageObjectType(), + ], true); + } elseif ($parser->getOutputType() == 'text/simplified-html') { + return StringUtil::getAnchorTag($foo->getLink(), $foo->getTitle()); + } + } +} +``` + +```smarty title="shared_bbcode_foo.tpl" + + + +``` + +## Open Image Viewer Manually + +The Image Viewer can also be created dynamically using the function `WoltLabSuite/Core/Component/Image/Viewer::createFancybox()`. +The contents of the modal are passed directly to the function. + +### Example + +The following code example creates a button that opens the Image Viewer with two images: + +```html + + + + +``` diff --git a/docs/migration/wsc61/deprecations_removals.md b/docs/migration/wsc61/deprecations_removals.md index e2d9a0af..6565ca8a 100644 --- a/docs/migration/wsc61/deprecations_removals.md +++ b/docs/migration/wsc61/deprecations_removals.md @@ -22,3 +22,7 @@ With version 6.2, we have deprecated certain components and removed several othe #### Properties - `wcf\system\option\user\DateUserOptionOutput::$dateFormat` ([WoltLab/WCF#6042](https://github.com/WoltLab/WCF/pull/6042/)) + +### JavaScript + +- `WCF.ImageViewer` ([WoltLab/WCF#6035](https://github.com/WoltLab/WCF/pull/6035/)) diff --git a/mkdocs.yml b/mkdocs.yml index 75acd5a3..e992b066 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -66,6 +66,7 @@ nav: - 'Dialog': 'javascript/components_dialog.md' - 'Google Maps': 'javascript/components_google_maps.md' - 'Guest Token': 'javascript/components_guest_token.md' + - 'Image Viewer': 'javascript/components_image_viewer.md' - 'Notices': 'javascript/components_notice.md' - 'Pagination': 'javascript/components_pagination.md' - 'RPC API': 'javascript/components_rpc_api.md'