繁体   English   中英

强制加载/显示的图像链接到colorbox中的html(我的帖子)页面

[英]Force loaded / displayed image to link to an html ( my post ) page in colorbox

我正在使用自定义元数据将图像显示为wordpress中的帖子。 当我单击主页上的图像时,它会在颜色框中打开,这很完美。

发生了什么:现在,将图像加载到颜色盒中后,当我单击图像时,它会循环浏览我主页上的图像(不是我想要的)。

我将要发生的事情:将图像加载到色箱中时,当我单击它时,它将作为链接并将帖子(与该图像关联)加载到色箱中。

我不清楚如何执行此操作。 我用于显示帖子的图像元数据的代码是:

        <?php

        // check for spine image
        $spine = get_post_meta($post->ID, 'spine image', $single = true);

        // check for spine class
        $spine_class = get_post_meta($post->ID, 'spine class', $single = true);

    ?>

    <div style=" #position: center; #left: 50%; height: 650px; display: table-cell; vertical-align: middle;">

        <div class="post" id="post-<?php the_ID(); ?>">

            <div class="entry">

                <?php

                    // If there is a spine image, display it as the post
                    if($spine !== '') { ?>

                    <p>
                        <a rel="bookmark" href="<?php echo $spine; ?>" title="<?php the_title_attribute(); ?>">
                            <img src="<?php echo $spine; ?>" class="<?php if($spine_class !== '') { echo $spine_class; } else { echo "left"; } ?>"
                                height="400" onMouseOver='resizeImg(this, 150)' onMouseOut='resizeImg(this)'
                            />
                        </a>
                    </p>

                    <?php } // end if statement

                    // if there's not a spine image
                    else { echo ''; }
                ?>

            </div>

        </div>

    </div>

我用于colorbox的功能是:

<script type="text/javascript">
$(document).ready(function(){
    //Examples of how to assign the ColorBox event to elements
    $("a[rel='bookmark']").colorbox({transition:"fade"});
});
</script>

这样带有“书签”属性的链接将在颜色框中打开。 现在我该如何做,以便颜色盒中的图像链接到关联的网页(或充当到任何网页的链接……一次一步)?

我希望这是有道理的,谢谢您的帮助,mlord

一旦我意识到如何做到这一点,我的问题似乎就会变得过于复杂。

最终结果是,我使用了网站( http://colorpowered.com/colorbox/core/example4/index.html )上的“ .inline” HTML结构化示例。 我可以将图像从wordpress循环href链接到永久链接,并为要在颜色框中显示的每个图像/帖子内联调用它。 然后,我在该链接上包含了常规的colorbox类,该类也打开了colorbox内部的帖子。 太棒了!

保持照顾,马修

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM