From 4e7da2799c1b9f97267bd2cb9de0d2dae52afcfe Mon Sep 17 00:00:00 2001 From: Grischa Brockhaus Date: Mon, 5 Dec 2022 00:54:04 +0100 Subject: [PATCH 1/2] Version 1.03 * imgages in body-attach with title / alt attribute get them removed while adding fancy attributes * Added fancybox to image inlined in posts. Un-hooked the old lightbox from frio and vier and excahnged that with fancybox hooks. * Excluded images in "type-link" divs from being "fancied" as they have no images but pages linked to. --- fancybox/CHANGELOG.md | 10 ++++ fancybox/asset/fancybox/fancybox.config.js | 1 + fancybox/createrelease | 2 +- fancybox/fancybox.php | 62 ++++++++++++++-------- 4 files changed, 51 insertions(+), 24 deletions(-) diff --git a/fancybox/CHANGELOG.md b/fancybox/CHANGELOG.md index 60edc6357..3d676c0c9 100644 --- a/fancybox/CHANGELOG.md +++ b/fancybox/CHANGELOG.md @@ -1,3 +1,13 @@ +### Version 1.03 + +* imgages in body-attach with title / alt attribute get them removed while adding fancy attributes +* Added fancybox to image inlined in posts. Un-hooked the old lightbox from frio and vier and excahnged that with fancybox hooks. +* Excluded images in "type-link" divs from being "fancied" as they have no images but pages linked to. + +### Version 1.02 + +* [MrPetovan](https://github.com/MrPetovan) optimized my noob regular expression code. + ### Version 1.01 * One gallery for each post diff --git a/fancybox/asset/fancybox/fancybox.config.js b/fancybox/asset/fancybox/fancybox.config.js index 904390d5a..6ac5d9c55 100644 --- a/fancybox/asset/fancybox/fancybox.config.js +++ b/fancybox/asset/fancybox/fancybox.config.js @@ -1,3 +1,4 @@ $(document).ready(function() { $.fancybox.defaults.loop = "true"; + $("body").off("click", ".wall-item-body a img"); }); \ No newline at end of file diff --git a/fancybox/createrelease b/fancybox/createrelease index 6760c242e..238828d69 100755 --- a/fancybox/createrelease +++ b/fancybox/createrelease @@ -11,7 +11,7 @@ rm $MODULE/dist/* # create release for actual version zip -r9 $MODULE/dist/release.zip $MODULE/* -x $MODULE/dist/\* -x $MODULE/test/\* $MODULE/createrelease -echo release/release.zip created. +echo dist/release.zip created. cd $MODULE diff --git a/fancybox/fancybox.php b/fancybox/fancybox.php index f3a566a50..1400a75c6 100644 --- a/fancybox/fancybox.php +++ b/fancybox/fancybox.php @@ -2,7 +2,7 @@ /** * Name: Fancybox * Description: Open media attachments of posts into a fancybox overlay. - * Version: 1.01 + * Version: 1.03 * Author: Grischa Brockhaus */ @@ -28,27 +28,43 @@ function fancybox_footer(App $a, string &$str) DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js'); } -function fancybox_render(App $a, array &$b) -{ - $matches = []; - $pattern = '#
.*?
#s'; - $gallery = 'gallery'; - if (array_key_exists('item', $b)) { - $item = $b['item']; - if (array_key_exists('uri-id', $item)) { - $gallery = $gallery . '-' . $item['uri-id']; - } +function fancybox_render($a, array &$b){ + $gallery = 'gallery-' . $b['item']['uri-id'] ?? random_int(1000000, 10000000); + + // prevent urls in #s', + function ($matches) use ($gallery) { + return str_replace(' Date: Mon, 5 Dec 2022 12:46:18 +0100 Subject: [PATCH 2/2] Changes added because of good remarks by hypolite@friendica.mrpetovan.com --- fancybox/asset/fancybox/fancybox.config.js | 1 + fancybox/fancybox.php | 56 +++++++++------------- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/fancybox/asset/fancybox/fancybox.config.js b/fancybox/asset/fancybox/fancybox.config.js index 6ac5d9c55..2b9c4f418 100644 --- a/fancybox/asset/fancybox/fancybox.config.js +++ b/fancybox/asset/fancybox/fancybox.config.js @@ -1,4 +1,5 @@ $(document).ready(function() { $.fancybox.defaults.loop = "true"; + // this disables the colorbox hook found in frio/js/modal.js:34 $("body").off("click", ".wall-item-body a img"); }); \ No newline at end of file diff --git a/fancybox/fancybox.php b/fancybox/fancybox.php index 1400a75c6..43219103b 100644 --- a/fancybox/fancybox.php +++ b/fancybox/fancybox.php @@ -28,43 +28,33 @@ function fancybox_footer(App $a, string &$str) DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js'); } -function fancybox_render($a, array &$b){ +function fancybox_render(App $a, array &$b){ $gallery = 'gallery-' . $b['item']['uri-id'] ?? random_int(1000000, 10000000); - // prevent urls in #s', - function ($matches) use ($gallery) { - return str_replace('