WordPress原生的“播放列表”短码。Next和Prev都有,但没有图标。怎么修?

时间:2014-09-12 作者:ginolin

如果我在Wordpress 4.0上使用美丽的播放列表快捷码,我看不到著名的“Next”和“Prev”图标,但在Html代码中只看到以下代码:

<div class="wp-playlist-next"></div>

<div class="wp-playlist-prev"></div>

如何为next和prev命令显示图标?

2 个回复
SO网友:T.Todua

在样式表中:

.wp-playlist-prev{
   width:20px;
   height:20px;
   background-image: url("./theme_images_folder/something_icon.png");
}
“下一步”按钮也是如此

SO网友:bonger

要把它们放在酒吧里,你可以忽略那些漂亮的WP播放列表,使用mediaelement添加你自己的。js直接,类似于this question.

你基本上扩展了MediaElementPlayer 通过书写buildXXX 函数,然后在设置中指定它们features 属性作为数组(以及所有其他控件)。

下面通过挂接wp_playlist_scripts 行动的优先顺序为9,足够早,有望延长MediaElementPlayer 和WP_wpmejsSettings 在创建播放列表之前启动wp-mediaelement.

(为了简单起见dashicons 此处用于设置样式。)

add_action( \'wp_playlist_scripts\', function () {
wp_enqueue_style( \'dashicons\' );
?>
<style>
.mejs-prev span, .mejs-next span {
    color:#eee; cursor:pointer; display:inline-block; font-family:"dashicons"; margin-top:5px;
}
</style>
<script>
(function ($) {
    if (typeof MediaElementPlayer !== \'undefined\' && typeof _wpmejsSettings !== \'undefined\') {
        $.extend(MediaElementPlayer.prototype, {
            buildprev: function(player, controls, layers, media) {
                var tracks = $(\'.wp-playlist-tracks .wp-playlist-item\', controls.closest(\'.wp-playlist\'));
                if (tracks.length > 1) {
                    $(\'<div class="mejs-button mejs-prev-button mejs-prev" >\' +
                        \'<span class="dashicons dashicons-arrow-left-alt2" title="\' + this.options.prevText + \'"></span>\' +
                    \'</div>\').appendTo(controls).on(\'click\', function (event) {
                        event.stopPropagation();
                        tracks.each(function (index) {
                            if ($(this).hasClass(\'wp-playlist-playing\') ) {
                                index = (index - 1) % tracks.length;
                                tracks.get(index).click();
                                return false;
                            }
                        });
                    });
                }
            },
            buildnext: function(player, controls, layers, media) {
                var tracks = $(\'.wp-playlist-tracks .wp-playlist-item\', controls.closest(\'.wp-playlist\'));
                if (tracks.length > 1) {
                    $(\'<div class="mejs-button mejs-next-button mejs-next" >\' +
                        \'<span class="dashicons dashicons-arrow-right-alt2" title="\' + this.options.nextText + \'"></span>\' +
                    \'</div>\').appendTo(controls).on(\'click\', function (event) {
                        event.stopPropagation();
                        tracks.each(function (index) {
                            if ($(this).hasClass(\'wp-playlist-playing\') ) {
                                index = (index + 1) % tracks.length;
                                tracks.get(index).click();
                                return false;
                            }
                        });
                    });
                }
            }
        });
        $.extend(_wpmejsSettings, {
            // Put these in the order you want.
            features: [\'playpause\',\'current\',\'progress\',\'duration\',\'tracks\',\'volume\',\'fullscreen\',\'prev\',\'next\'],
            prevText: <?php echo json_encode( __( \'Previous track\' ) ); ?>,
            nextText: <?php echo json_encode( __( \'Next track\' ) ); ?>
        });
    }
})(jQuery);
</script>
<?php
}, 9 );

结束

相关推荐

favicon now showing up

我在我的服务器上的/home目录中安装了wordpress,因此设置为您必须访问www.mywordpress。com/home查看我的wordpress,然后访问www.mywordpress。com将带您进入另一个主页。嗯,我进入我的设置,将网站Url更改为www.mywordpress。这样我的wordpress就会成为我的主页。今天,我试着设置一个favicon,它只在url为www.mywordpress时起作用。com/home/whatever,即使你尝试访问www.mywordpress。