Page 1 of 1

Image modal struggles

Posted: Mon Aug 24, 2020 11:08 am
by YawningHippo
A gallery design I frequently encounter is the clickable image (thumbnail) resulting in modal image upon clicking:

Code: Select all

<a href="fulls/01.jpg"><img src="thumbs/01.jpg" alt=""></a
I've tried to recreate this in WonderCMS and make it (summernote) editor compatible:

Code: Select all

<?php if($Wcms->loggedIn) { ?>
	<?= $Wcms->block('gallery_01') ?>
<?php } else { ?>
	<a href='<?php echo img_link($Wcms->block('gallery_01')) ?>'><?= $Wcms->block('gallery_01') ?></a>
<?php } ?>
The function img_link being defined in functions.php:

Code: Select all

function img_link($img) {

    global $Wcms;

    $lefttrim = ltrim($img, '<img src=\"');
    $result = rtrim($lefttrim, '"/>');

    return $result;
}
This shows only the image when logged in, editable with summernote like any other image.
When nobody is logged in, it functions as the clickable thumbnail in the original design, Succes!

Or so I thought... :roll:
Any image uploaded using the summernote filepicker results in a massive database entry, resulting in the following:
Capture.PNG
Capture.PNG (7.82 KiB) Viewed 22928 times
Since the url format probably can't be altered/shortened, I guess this isn't gonna work and this design is just not filepicker compatible. :-(
Please tell me if I missed anything or if anyone has had more succes with this in previous endeavors!