mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-25 16:03:15 +00:00
Changes added because of good remarks by hypolite@friendica.mrpetovan.com
This commit is contained in:
parent
4e7da2799c
commit
c6d09e5270
2 changed files with 24 additions and 33 deletions
|
@ -1,4 +1,5 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$.fancybox.defaults.loop = "true";
|
$.fancybox.defaults.loop = "true";
|
||||||
|
// this disables the colorbox hook found in frio/js/modal.js:34
|
||||||
$("body").off("click", ".wall-item-body a img");
|
$("body").off("click", ".wall-item-body a img");
|
||||||
});
|
});
|
|
@ -28,43 +28,33 @@ function fancybox_footer(App $a, string &$str)
|
||||||
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js');
|
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);
|
$gallery = 'gallery-' . $b['item']['uri-id'] ?? random_int(1000000, 10000000);
|
||||||
|
|
||||||
// prevent urls in <div class="type-link"> to be replaced
|
// performWithEscapedBlocks escapes block defined with 2nd par pattern that won't be processed.
|
||||||
$b['html'] = preg_replace_callback(
|
// We don't want to touch images in class="type-link":
|
||||||
|
$b['html'] = \Friendica\Util\Strings::performWithEscapedBlocks(
|
||||||
|
$b['html'],
|
||||||
'#<div class="type-link">.*?</div>#s',
|
'#<div class="type-link">.*?</div>#s',
|
||||||
function ($matches) use ($gallery) {
|
function ($text) use ($gallery) {
|
||||||
return str_replace('<a href', '<a data-nofancybox="" href', $matches[0]);
|
|
||||||
},
|
|
||||||
$b['html']
|
|
||||||
);
|
|
||||||
|
|
||||||
// This processes images inlined in posts
|
// This processes images inlined in posts
|
||||||
// Frio / Vier hooks für lightbox are un-hooked in fancybox-config.js. So this works for them, too!
|
// Frio / Vier hooks für lightbox are un-hooked in fancybox-config.js. So this works for them, too!
|
||||||
//if (!in_array($a->getCurrentTheme(),['vier','frio']))
|
//if (!in_array($a->getCurrentTheme(),['vier','frio']))
|
||||||
{
|
$text = preg_replace(
|
||||||
// normal post inline linked images
|
|
||||||
$b['html'] = preg_replace_callback(
|
|
||||||
'#<a[^>]*href="([^"]*)"[^>]*>(<img[^>]*src="[^"]*"[^>]*>)</a>#',
|
'#<a[^>]*href="([^"]*)"[^>]*>(<img[^>]*src="[^"]*"[^>]*>)</a>#',
|
||||||
function ($matches) use ($gallery) {
|
'<a data-fancybox="' . $gallery . '" href="$1">$2</a>',
|
||||||
// don't touch URLS marked as not "fancyable".. ;-)
|
$text);
|
||||||
if (preg_match('#data-nofancybox#', $matches[0]))
|
|
||||||
{
|
|
||||||
return $matches[0];
|
|
||||||
}
|
|
||||||
return '<a data-fancybox="' . $gallery . '" href="'. $matches[1] .'">' . $matches[2] .'</a>';
|
|
||||||
},
|
|
||||||
$b['html']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Local content images attached:
|
// Local content images attached:
|
||||||
$b['html'] = preg_replace_callback(
|
$text = preg_replace_callback(
|
||||||
'#<div class="body-attach">.*?</div>#s',
|
'#<div class="body-attach">.*?</div>#s',
|
||||||
function ($matches) use ($gallery) {
|
function ($matches) use ($gallery) {
|
||||||
return str_replace('<a href', '<a data-fancybox="' . $gallery . '" href', $matches[0]);
|
return str_replace('<a href', '<a data-fancybox="' . $gallery . '" href', $matches[0]);
|
||||||
},
|
},
|
||||||
$b['html']
|
$text
|
||||||
|
);
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue