WordPress的Jquery在我的localhost上工作但是在ulploading文件后它停止工作了吗?

时间:2011-01-20 05:07:58

标签: jquery wordpress

我在我的localhost中的Wordpress页面中安装了WordView的Jquery:

http://localhost/brianfunshine.com2/

图像正确显示在灯箱中

http://alex-chen.net/wordpress/

但是当我将文件上传到服务器时,Jquery for Wordpress停止了工作。

我刚刚上传了Wordpress主题和插件。

我不确定要提供哪些代码。

请让我知道如何解决这个问题。

图像链接的代码(在本例中是视频):

<div><a href="#second2"><img src="http://www.howieolson.com/wp-content/uploads/2010/04/howie-olsen-welcome-video.jpg" alt="Welcome To High Output" width="220px" height="120px" /></a></div>
<div id="second2" style="display: none;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/N172nW_U39g?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/N172nW_U39g?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>

修改

该插件表示它本身就是直接链接。当我从我的localhost使用它时它会这样做。

当我上传文件时,我必须为链接分配类:“fancybox”以使其正常工作。

我不知道Javascript,但我认为插件会在这里搜索直接链接:

// Load FancyBox with the settings set
function mfbfw_init() {

    $settings = mfbfw_get_settings();

    echo "\n"."\n"."<!-- Fancybox for WordPress v". $settings['version'] ." -->"."\n";

    ?>

<script type="text/javascript">

    <?php if ($settings['jQnoConflict']) { ?>jQuery.noConflict();<?php } echo "\n" ?>

    jQuery(function(){

        <?php // This copies the title of every IMG tag and adds it to its parent A so that fancybox can use it ?>
        jQuery.fn.getTitle = function() {
            var arr = jQuery("a.fancybox");
            jQuery.each(arr, function() {
                var title = jQuery(this).children("img").attr("title");
                jQuery(this).attr('title',title);
            })
        }

        // Supported file extensions
        var thumbnails = 'a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';

    <?php if ($settings['galleryType'] == 'post') {

        // Gallery type BY POST and we are on post or page (so only one post or page is visible)
        if ( is_single() | is_page() ) { ?>

        jQuery(thumbnails).addClass("fancybox").attr("rel","fancybox").getTitle();

    <?php }

    // Gallery type BY POST, but we are neither on post or page, so we make a different rel attribute on each post
    // (optimized based on sugestions from http://mentalfruition.com/)
    else { ?>

        var posts = jQuery('.post');

        posts.each(function() {
            jQuery(this).find(thumbnails).addClass("fancybox").attr('rel','fancybox'+posts.index(this)).getTitle()
        });


    <?php }

    }

1 个答案:

答案 0 :(得分:1)

插件选择器使用has(img)来确定是否应将fancybox类添加到链接中。

var thumbnails = 'a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';


jQuery(thumbnails).addClass("fancybox").attr("rel","fancybox").getTitle();

has(img)正在链接(标签)中寻找一个img标签,而不是像以下那样链接到图像:

<a href="http://img155.imageshack.us/img155/4065/screenshot2lx.png">click here</a>

它需要类似以下内容才能自动运行:

<a href="http://img155.imageshack.us/img155/4065/screenshot2lx.png"><img src="<thumbnail url>" /></a>