Help for digital viewer development

57 views
Skip to first unread message

Isabel Martín

unread,
Jun 5, 2019, 3:38:31 AM6/5/19
to AtoM Users
Good morning, I tell you a question about code that I can not make work.

Given the large number of digital documents that have the descriptions of my AtoM, I have decided to change imageflow by a JQuery image viewer called lightgallery.

The code is the following:

<?php use_helper('Text') ?>
<?php //INFO: Partial show a default image and link all digitalobject for this informatioobject ?>


<?php $childrens = $resource->getChildren(); ?>
<?php if (sizeof($childrens) > 0 && $childrens[0]->getDigitalObject() != null): ?>

<div class="digital-object-reference row">
        <!--<div class="span2"><?php // image_tag($childrens[0]->getDigitalObject()->getPublicPath(), 'id = dynamic'); ?></div>-->
        <div class="span2"><?php echo image_tag($childrens[0]->getDigitalObjectPublicUrl(), 'id = dynamic'); ?></div>
        <div class="span4">
                <p class="lead">
                        <?php echo $resource->title; ?>
                </p>
                <p>
                        <strong>Número de páginas: </strong><?php echo sizeof($childrens); ?>
                </p>
                <p>Haga clic en la imagen para ver el documento completo.</p>
        </div>
</div>
        <?php $arrayPaginas = "[ \n"; ?>
        <?php foreach ($childrens as $child): ?>
                <?php $arrayPaginas .= "{ \n"; ?>
                <?php $arrayPaginas .= "'src': '".$child->getDigitalObjectPublicUrl()."',"; ?>
                <?php $images = $child->getDigitalObject(); ?>
                Hijos del documento: <?php echo sizeof($images); ?>
                <?php $arrayPaginas .= "'thumb': '".$child->getDigitalObjectPublicUrl()."',"; ?>
                <?php $arrayPaginas .= "'subHtml': '<h4>".esc_entities($child->getDigitalObject()->name, 100)."</h4>'"; ?>
                <?php $arrayPaginas .= "}"; ?>
                <?php $arrayPaginas .= ",\n"; ?>
        <?php endforeach; ?>
        <?php $arrayPaginas = substr($arrayPaginas, 0, -1); ?>
        <?php $arrayPaginas .= "                    ]\n"; ?>

<div class="galeria">

                        <script type="text/javascript">

                                jQuery(document).ready(function(){

                                        jQuery('#dynamic').on('click', function() {
                                                jQuery(this).lightGallery({
                                                        hideControlOnEnd: true,
                                                        loop: false,
                                                        swipeThreshold: 50,
                                                        pager: true,
                                                        closable: false,
                                                        dynamic: true,
                                                        dynamicEl: <?php echo $arrayPaginas; ?>
                                                })
                                        });

                                });
                        </script>

        </div>
<?php endif; ?>



I get the first image of the first digitalobject of the informationobject and show it. This image is what I use to launch the script with the click event.

In the script I will create an array of objects that will be the images of digital objects. Each object has a src key, which contains the copy image of lower quality than the master image; another thumb which is the thumbnail, and a subHTML key that is used as the image title.

My question is how to get the lower quality image and the thumbnail to include in the script given that I do not understand well how the informationobject model relates to digitalobject and how the three images are related: the teacher, the copy and the thumbnail.

A greeting.

David at Artefactual

unread,
Jun 6, 2019, 1:26:55 PM6/6/19
to AtoM Users
Hi Isabel,

You can get the thumbnail "object" for a given "master' digital object with:

$item->getRepresentationByUsage(QubitTerm::THUMBNAIL_ID);




To get the "reference" representation for a digital object, you can use:


In the data model the reference digital object and thumbnail digital object are both children of the "master" digital object (e.g. thumbail.parent_id = master.id), so you can get the reference and thumbail rows in the database with a query like:

"SELECT * FROM digital_object WHERE parent_id=1234;" (where '1234' represents the primary key of the "master" digital object)

I hope that helps!



Best regards,

David Juhasz
Senior Developer

Artefactual Systems Inc.
www.artefactual.com

Isabel Martín

unread,
Jun 13, 2019, 3:57:05 AM6/13/19
to AtoM Users
Good morning David, thanks for the reply. I am currently with another part of the project and I have the most abandoned development, 
I have not yet tested it. I inform you when I do. Thanks again for your help.
Reply all
Reply to author
Forward
0 new messages