在弹出窗口中打开放大的图像时,我如何添加“点击放大图像”功能?

时间:2013-03-19 作者:ProfK

我有几个UI表单和任务的图像,它们非常大。我想显示一个较小的“缩略图”图像snf为用户提供“单击放大”选项,然后在弹出窗口或单独的窗口或选项卡中显示填充大小图像。我不赞成弹出窗口,但这是我必须做出的决定。

我该怎么办?我将把加载全尺寸图像并打开新窗口的JavaScript放在哪里?

2 个回复
SO网友:Jamie

你应该用灯箱来做这个。试试这个。它工作得很好

http://lokeshdhakar.com/projects/lightbox2/

有关于如何使用它的说明和关于如何使其工作的文档。下载还将包含示例,您可以复制并粘贴代码。

SO网友:ehtesham
<?php get_header(); ?>
<?php get_sidebar();?>
    <div id="content">
        <?php if ( have_posts() ) : ?>
            <?php while ( have_posts() ) : the_post(); ?>
                <article id="post-<?php the_ID(); ?>" <?php post_class($class); ?>>
                    <header class="entry-header">
                        <?php if(has_post_thumbnail()):?>
                            <?php the_post_thumbnail(); ?>
                        <?php endif; ?>
                        <h1 class="entry-title">
                            <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( \'Permalink to %s\', \'ifoti\' ), the_title_attribute( \'echo=0\' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
                        </h1>
                        <?php if ( \'post\' == get_post_type() ) : ?>
                        <div class="entry-meta">
                            <?php ifoti_posted_on(); ?>
                        </div><!-- .entry-meta -->
                        <?php endif; ?>
                    </header><!-- .entry-header -->

                    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
                    <div class="entry-summary">
                        <?php the_excerpt(); ?>
                    </div><!-- .entry-summary -->
                    <?php else : ?>
                    <div class="entry-content">
                        <?php the_content( __( \'Continue reading <span class="meta-nav">&rarr;</span>\', \'ifoti\' ) ); ?>
                        <?php wp_link_pages( array( \'before\' => \'<div class="page-link"><span>\' . __( \'Pages:\', \'ifoti\' ) . \'</span>\', \'after\' => \'</div>\' ) ); ?>
                    </div><!-- .entry-content -->
                    <?php endif; ?>

                    <footer class="entry-meta">
                        <?php $show_sep = false; ?>
                        <?php if ( \'post\' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
                        <?php
                            $categories_list = get_the_category_list( __( \', \', \'ifoti\' ) );
                            if ( $categories_list ):
                        ?>
                        <span class="cat-links">
                            <?php printf( __( \'<span class="%1$s">Posted in</span> %2$s\', \'ifoti\' ), \'entry-utility-prep entry-utility-prep-cat-links\', $categories_list );
                            $show_sep = true; ?>
                        </span>
                        <?php endif; // End if categories ?>
                        <?php
                            $tags_list = get_the_tag_list( \'\', __( \', \', \'ifoti\' ) );
                            if ( $tags_list ):
                            if ( $show_sep ) : ?>
                        <span class="sep"> | </span>
                            <?php endif; // End if $show_sep ?>
                        <span class="tag-links">
                            <?php printf( __( \'<span class="%1$s">Tagged</span> %2$s\', \'ifoti\' ), \'entry-utility-prep entry-utility-prep-tag-links\', $tags_list );
                            $show_sep = true; ?>
                        </span>
                        <?php endif; // End if $tags_list ?>
                        <?php endif; // End if \'post\' == get_post_type() ?>

                        <?php if ( comments_open() ) : ?>
                        <?php if ( $show_sep ) : ?>
                        <span class="sep"> | </span>
                        <?php endif; // End if $show_sep ?>
                        <span class="comments-link"><?php comments_popup_link( \'<span class="leave-reply">\' . __( \'Leave a reply\', \'ifoti\' ) . \'</span>\', __( \'<b>1</b> Reply\', \'ifoti\' ), __( \'<b>%</b> Replies\', \'ifoti\' ) ); ?></span>
                        <?php endif; // End if comments_open() ?>
                        <span class="sep"> | </span>
                        <?php edit_post_link( __( \'Edit\', \'ifoti\' ), \'<span class="edit-link">\', \'</span>\' ); ?>
                    </footer><!-- #entry-meta -->
                    <div class="socialbtn">
                        <!-- AddThis Button BEGIN -->
                        <div class="addthis_toolbox addthis_default_style"addthis:url="<?php the_permalink() ?>">
                            <a class="addthis_button_email">Email</a>
                            <a class="addthis_button_print">Print</a>
                            <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
                            <a class="addthis_button_tweet"></a>
                            <a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
                        </div>
                        <script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
                        <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f97067f47ad8fdb"></script>
                        <!-- AddThis Button END -->
                    </div>

                    <div>
                        <?php comments_template();?>
                    </div>
                </article><!-- #post-<?php the_ID(); ?> -->
            <?php endwhile; ?>
        <?php else : ?>
            No Result;
        <?php endif; ?>
    </div>
<?php get_footer(); ?>

List item

结束

相关推荐

Some images 404

我将我们的旧博客迁移到主根目录中的同一服务器。出于某种原因,即使在/uploads/folder中,也不会再加载一些图像。当以URL的形式访问它们时,我得到了404,但我可以直接从FTP(和工作)下载它们。有人知道问题出在哪里吗?我在想我的。htaccess文件,但我不确定这是问题所在:<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\\.php$ - [L] R