小编Pol*_*fra的帖子

从youtube网址获取持续时间

我正在寻找一个能从网址中提取视频的youtube持续时间的功能.我读了一些教程,但没有得到它.我使用网址在我的网站上嵌入视频,我有一个拉缩略图的功能,我只想要类似的东西来获取持续时间.这是我如何得到拇指......

function get_youtube_screen_link( $url = '', $type = 'default', $echo = true ) {
if( empty( $url ) )
    return false;

if( !isset( $type ) )
    $type = '';

$url = esc_url( $url );

preg_match("|[\\?&]v=([^&#]*)|",$url,$vid_id);

if( !isset( $vid_id[1] ) )
    return false;

$img_server_num =  'i'. rand(1,4);

switch( $type ) {
    case 'large':
        $img_link = "http://{$img_server_num}.ytimg.com/vi/{$vid_id[1]}/0.jpg";
        break;
    case 'first':
        // Thumbnail of the first frame
        $img_link = "http://{$img_server_num}.ytimg.com/vi/{$vid_id[1]}/1.jpg";
        break;
    case 'small':
        // Thumbnail of a later frame(i'm not sure how they …
Run Code Online (Sandbox Code Playgroud)

youtube meta

9
推荐指数
2
解决办法
2万
查看次数

如何使用Jquery检索wordpress的ajax搜索结果

我需要设置wordpress ajax搜索结果,但我的方法是在单击按钮时不检索结果,而是将我重定向到另一个站点(myurl.com?s=term).我正确地调用了admin-ajax.php但是设置错误了.是什么原因造成了这个问题?

//Script to activate ajax
 jQuery(document).ready(function($){
  var search_val=$("#s").val();
  $('#searchsubmit').click(function(){
    $.post(
        WPaAjax.ajaxurl,
        {
            action : 'wpa56343_search',
            search_val : search_val
        },
        function( response ) {
            $('#results').append( response );
        }
    );
   });

 });

//function to setup wp_query
add_action('wp_ajax_wpa56343_search', 'wpa56343_search');
function wpa56343_search(){
  global $wp_query;
  $search = $_POST['search_val'];
  $args = array(
    's' => $search,
    'posts_per_page' => 5
  );
  $wp_query = new WP_Query( $args );

  get_template_part( 'search-results' );

  exit;
}

//html

  <div id="my_search">
   <form role="search" method="get" id="searchform" action="http://myurl.com/" >
    <input type="text" value="" name="s" id="s" /> …
Run Code Online (Sandbox Code Playgroud)

wordpress search jquery

8
推荐指数
1
解决办法
2万
查看次数

如何使用新的ajax内容进行无限滚动重置

在我的主页上,我有一个使用无限滚动的帖子循环.用户可以使用ajax(如ajax搜索等)将该循环替换为其他循环.我的问题是无限滚动仅在第一次使用时才起作用,因此如果它被主循环触发,那么当新循环替换主循环时它将不再起作用.每次新循环替换旧循环时,重新加载以下函数.因此,每次调用新循环时,如何进行无限滚动重置和工作?

var href = 'first';
$(document).ready(function() {
    $('#boxes').infinitescroll({
        navSelector: '.infinitescroll',
        nextSelector: '.infinitescroll a',
        itemSelector: '#boxes .box',
        loadingImg: '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',
        loadingText: 'Loading...',
        donetext: 'No more pages to load.',
        debug: false
    }, function(arrayOfNewElems) {
        $('#boxes').masonry('appended', $(arrayOfNewElems));
        if(href != $('.infinitescroll a').attr('href')) {
            href = $('.infinitescroll a').attr('href');
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

我在wordpress网站上使用Pual Irish无限滚动插件的最新版本2.0b2.120519 .

jquery loops infinite-scroll

6
推荐指数
1
解决办法
8626
查看次数

如何在没有浏览器嗅探的情况下区分台式机和平板电脑的1000px屏幕大小?

我在网站的桌面版本上使用了很多过渡,悬停和阴影效果。我需要为平板电脑版本摆脱它们,我以为我可以处理媒体查询,但是我的问题是,当我使用@media only screen和(min-width:1224px)之类的东西来定位台式机时,用户需要他们的浏览器窗口已最大化,或者他们获得了针对平板电脑的CSS。因此,如果桌面用户浏览器的分辨率为1000px,则它们与Ipad上的用户获得的CSS相同。现在,我被告知浏览器嗅探是不可靠的,那么如何区分1000px桌面浏览器和1000px平板电脑设备上的用户呢?

desktop tablet media-queries responsive-design

5
推荐指数
1
解决办法
1080
查看次数

使最后的内联列表项扩展容器的剩余宽度

我正在寻找一种方法来使最后的内联列表项扩展其容器的其余部分.所以我有这样的事情.

<nav>
  <ul>
     <li></li> //width = 50px
     <li></li> //width = 50px
     <li class="last"></li> //width needs to fill the remaining 300px
  </ul>
</nav>

nav {
  width:400px;
  height:50px;
}
nav > ul > li {
  display:inline-block;
  padding:5px;
}
Run Code Online (Sandbox Code Playgroud)

现在列表项的数量不同,所以我不能将最后一个列表项设置为设置的宽度.我需要让它填充导航宽度中留下的任何东西.如何只使用css?

css list

5
推荐指数
1
解决办法
2881
查看次数

使用$(this)和FileReader()来定位结果

我正在尝试从文件输入中显示图像的ajax预览.使用FileReader()很容易,但我正在使用循环,所以当我将结果放在图像源中时,我需要使用$(this)来定位输入的循环项.这对我来说甚至没有意义所以我们走了.

我们有一个循环..

<li>
  <input type="file" class="image" />
  <img src="" class="preview" />
</li>
<li>
  <input type="file" class="image" />
  <img src="" class="preview" />
</li>
<li>
  <input type="file" class="image" />
  <img src="" class="preview" />
</li>
Run Code Online (Sandbox Code Playgroud)

所以现在让我们说选择第二个输入,现在我需要将FileReader的结果添加到它的图像src中.我如何定位第二个循环项及其内容来做东西?

 function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function (e) {
               // Here I need to use $(this) to target only the second list item's img.preview
               $('.preview').attr('src', e.target.result);
            };

            reader.readAsDataURL(input.files[0]);
        }
 }
Run Code Online (Sandbox Code Playgroud)

jquery file-upload filereader

2
推荐指数
1
解决办法
4万
查看次数