Skip to content

Commit

Permalink
Fix broken commit in #15040 that accidentally reverted previous changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwharton committed Jul 6, 2018
1 parent b33721c commit a012c45
Showing 1 changed file with 10 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,11 @@
"data": <?= /* @escapeNotVerified */ $block->getGalleryImagesJson() ?>,
"options": {
"nav": "<?= /* @escapeNotVerified */ $block->getVar("gallery/nav") ?>",
<?php if (($block->getVar("gallery/loop"))): ?>
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/loop") ?>,
<?php endif; ?>
<?php if (($block->getVar("gallery/keyboard"))): ?>
"keyboard": <?= /* @escapeNotVerified */ $block->getVar("gallery/keyboard") ?>,
<?php endif; ?>
<?php if (($block->getVar("gallery/arrows"))): ?>
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/arrows") ?>,
<?php endif; ?>
<?php if (($block->getVar("gallery/allowfullscreen"))): ?>
"allowfullscreen": <?= /* @escapeNotVerified */ $block->getVar("gallery/allowfullscreen") ?>,
<?php endif; ?>
<?php if (($block->getVar("gallery/caption"))): ?>
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/caption") ?>,
<?php endif; ?>
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/loop") ? 'true' : 'false' ?>,
"keyboard": <?= /* @escapeNotVerified */ $block->getVar("gallery/keyboard") ? 'true' : 'false' ?>,
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/arrows") ? 'true' : 'false' ?>,
"allowfullscreen": <?= /* @escapeNotVerified */ $block->getVar("gallery/allowfullscreen") ? 'true' : 'false' ?>,
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/caption") ? 'true' : 'false' ?>,
"width": "<?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_medium', 'width') ?>",
"thumbwidth": "<?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_small', 'width') ?>",
<?php if ($block->getImageAttribute('product_page_image_small', 'height') || $block->getImageAttribute('product_page_image_small', 'width')): ?>
Expand All @@ -79,28 +69,18 @@
"transitionduration": <?= /* @escapeNotVerified */ $block->getVar("gallery/transition/duration") ?>,
<?php endif; ?>
"transition": "<?= /* @escapeNotVerified */ $block->getVar("gallery/transition/effect") ?>",
<?php if (($block->getVar("gallery/navarrows"))): ?>
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/navarrows") ?>,
<?php endif; ?>
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/navarrows") ? 'true' : 'false' ?>,
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navtype") ?>",
"navdir": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navdir") ?>"
},
"fullscreen": {
"nav": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/nav") ?>",
<?php if ($block->getVar("gallery/fullscreen/loop")): ?>
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/loop") ?>,
<?php endif; ?>
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/loop") ? 'true' : 'false' ?>,
"navdir": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navdir") ?>",
<?php if ($block->getVar("gallery/transition/navarrows")): ?>
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navarrows") ?>,
<?php endif; ?>
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navarrows") ? 'true' : 'false' ?>,
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navtype") ?>",
<?php if ($block->getVar("gallery/fullscreen/arrows")): ?>
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/arrows") ?>,
<?php endif; ?>
<?php if ($block->getVar("gallery/fullscreen/caption")): ?>
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/caption") ?>,
<?php endif; ?>
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/arrows") ? 'true' : 'false' ?>,
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/caption") ? 'true' : 'false' ?>,
<?php if ($block->getVar("gallery/fullscreen/transition/duration")): ?>
"transitionduration": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/transition/duration") ?>,
<?php endif; ?>
Expand Down

3 comments on commit a012c45

@dnadle
Copy link

@dnadle dnadle commented on a012c45 Sep 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is setting "showCaption" but fotorama.js is expecting "captions".

@gwharton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is my understanding of the fotorama code that the function isExpectedCaption is called to determine whether the caption should be shown or not. This function has the contents of showCaption passed as the 2nd parameter. If showCaption is set to false, then the function always returns false. If showCaption is true, then it will return true aslong as captions is also set to true, which it is by default.

I dont claim to understand the difference between showCaption and captions and why there are two options, but the logic would suggest, that as both are set true by default, that setting either or both to false would result in the caption not being displayed and setting both to true, or not specifying either would result in the caption being displayed.

@chakravarthykalyan90
Copy link

@chakravarthykalyan90 chakravarthykalyan90 commented on a012c45 Nov 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We upgraded from 2.2.4 to 2.2.7 this change is not there. Still same old issue we are facing. Here is the code from Gallery.phtml

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * Product media data template
 *
 * @var $block \Magento\Catalog\Block\Product\View\Gallery
 */
?>
<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
    <div data-role="loader" class="loading-mask">
        <div class="loader">
            <img src="<?= $block->escapeUrl($block->getViewFileUrl('images/loader-1.gif')) ?>"
                 alt="<?= $block->escapeHtml(__('Loading...')) ?>">
        </div>
    </div>
</div>
<!--Fix for jumping content. Loader must be the same size as gallery.-->
<script>
    var config = {
            "width": <?= $block->escapeHtml($block->getImageAttribute('product_page_image_medium', 'width')) ?>,
            "thumbheight": <?= $block->escapeHtml($block->getImageAttribute('product_page_image_small', 'height')
                        ?: $block->getImageAttribute('product_page_image_small', 'width')); ?>,
            "navtype": "<?= $block->escapeHtml($block->getVar("gallery/navtype")) ?>",
            "height": <?= $block->escapeHtml($block->getImageAttribute('product_page_image_medium', 'height')) ?>
        },
        thumbBarHeight = 0,
        loader = document.querySelectorAll('[data-gallery-role="gallery-placeholder"] [data-role="loader"]')[0];

    if (config.navtype === 'horizontal') {
        thumbBarHeight = config.thumbheight;
    }

    loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
</script>
<script type="text/x-magento-init">
    {
        "[data-gallery-role=gallery-placeholder]": {
            "mage/gallery/gallery": {
                "mixins":["magnifier/magnify"],
                "magnifierOpts": <?= /* @noEscape */ $block->getMagnifier() ?>,
                "data": <?= /* @noEscape */ $block->getGalleryImagesJson() ?>,
                "options": {
                    "nav": "<?= $block->escapeHtml($block->getVar("gallery/nav")) ?>",
                    <?php if (($block->getVar("gallery/loop"))) : ?>
                        "loop": <?= $block->escapeHtml($block->getVar("gallery/loop")) ?>,
                    <?php endif; ?>
                    <?php if (($block->getVar("gallery/keyboard"))) : ?>
                        "keyboard": <?= $block->escapeHtml($block->getVar("gallery/keyboard")) ?>,
                    <?php endif; ?>
                    <?php if (($block->getVar("gallery/arrows"))) : ?>
                        "arrows": <?= $block->escapeHtml($block->getVar("gallery/arrows")) ?>,
                    <?php endif; ?>
                    <?php if (($block->getVar("gallery/allowfullscreen"))) : ?>
                        "allowfullscreen": <?= $block->escapeHtml($block->getVar("gallery/allowfullscreen")) ?>,
                    <?php endif; ?>
                    <?php if (is_bool($block->getVar("gallery/caption"))) : ?>
                        "showCaption": <?= /* @noEscape */ $block->getVar("gallery/caption") ? 'true' : 'false'; ?>,
                    <?php endif; ?>
                    <?php
                        $imgWidth = $block->getImageAttribute('product_page_image_medium', 'width');
                        $thumbWidth = $block->getImageAttribute('product_page_image_small', 'width');
                    ?>
                        "width": "<?= $block->escapeHtml($imgWidth) ?>",
                        "thumbwidth": "<?= $block->escapeHtml($thumbWidth) ?>",
                    <?php
                        $thumbHeight = $block->getImageAttribute('product_page_image_small', 'height')
                            ?: $block->getImageAttribute('product_page_image_small', 'width');
                    ?>
                    <?php if ($thumbHeight) : ?>
                        "thumbheight": <?= $block->escapeHtml($thumbHeight); ?>,
                    <?php endif; ?>
                    <?php if (($block->getVar("gallery/thumbmargin"))) : ?>
                        "thumbmargin": <?= (int)$block->getVar("gallery/thumbmargin"); ?>,
                    <?php endif; ?>
                    <?php
                        $imgHeight = $block->getImageAttribute('product_page_image_medium', 'height')
                            ?: $block->getImageAttribute('product_page_image_medium', 'width')
                    ?>
                    <?php if ($imgHeight) : ?>
                        "height": <?= $block->escapeHtml($imgHeight); ?>,
                    <?php endif; ?>
                    <?php if ($block->getVar("gallery/transition/duration")) : ?>
                        "transitionduration": <?= $block->escapeHtml($block->getVar("gallery/transition/duration")) ?>,
                    <?php endif; ?>
                    "transition": "<?= $block->escapeHtml($block->getVar("gallery/transition/effect")) ?>",
                    <?php if (($block->getVar("gallery/navarrows"))) : ?>
                        "navarrows": <?= $block->escapeHtml($block->getVar("gallery/navarrows")) ?>,
                    <?php endif; ?>
                    "navtype": "<?= $block->escapeHtml($block->getVar("gallery/navtype")) ?>",
                    "navdir": "<?= $block->escapeHtml($block->getVar("gallery/navdir")) ?>"
                },
                "fullscreen": {
                    "nav": "<?= $block->escapeHtml($block->getVar("gallery/fullscreen/nav")) ?>",
                    <?php if ($block->getVar("gallery/fullscreen/loop")) : ?>
                        "loop": <?= $block->escapeHtml($block->getVar("gallery/fullscreen/loop")) ?>,
                    <?php endif; ?>
                    "navdir": "<?= $block->escapeHtml($block->getVar("gallery/fullscreen/navdir")) ?>",
                    <?php if ($block->getVar("gallery/transition/navarrows")) : ?>
                        "navarrows": <?= $block->escapeHtml($block->getVar("gallery/fullscreen/navarrows")) ?>,
                    <?php endif; ?>
                    "navtype": "<?= $block->escapeHtml($block->getVar("gallery/fullscreen/navtype")) ?>",
                    <?php if ($block->getVar("gallery/fullscreen/arrows")) : ?>
                        "arrows": <?= $block->escapeHtml($block->getVar("gallery/fullscreen/arrows")) ?>,
                    <?php endif; ?>
                    <?php if (is_bool($block->getVar("gallery/fullscreen/caption"))) : ?>
                        <?php $showCaption = $block->getVar("gallery/fullscreen/caption") ? 'true' : 'false'; ?>
                        "showCaption": <?= /* @noEscape */ $showCaption ?>,
                    <?php endif; ?>
                    <?php if ($block->getVar("gallery/fullscreen/transition/duration")) : ?>
                        "transitionduration": <?=
                        $block->escapeHtml($block->getVar("gallery/fullscreen/transition/duration")) ?>,
                    <?php endif; ?>
                    "transition": "<?= $block->escapeHtml($block->getVar("gallery/fullscreen/transition/effect")) ?>"
                },
                "breakpoints": <?= /* @noEscape */ $block->getBreakpoints() ?>
            }
        }
    }
</script>

Please sign in to comment.