functions.php

1
2
3
4
5
//I commented the condition because it seems there is a bug with this on my website, but normally you should uncomment it.
//JS
//if (is_page_template('gallery.php'))
  wp_enqueue_script( 'galleries-scripts', get_bloginfo('stylesheet_directory').'/js/galleries-scripts.js', array('jquery'),'0.1');

galleries-scripts.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
jQuery(document).ready( function() {

  jQuery('#mediaspace').each(function(i){
    container = jQuery(this).children('.pro-player-container');
    object = container.children('object');
    object_id = object.attr('id');

    //set container ID
    object_id_split = object_id.split('-');
    object_id_last_split = object_id_split[object_id_split.length-1];
    container_id = 'pro-player-container-'+object_id_last_split;
    container.attr('id',container_id);

    //get flashvars
    flashvars = object.children("param[name='flashvars']").val();

    image = get_proplayer_flashvars('image',flashvars);
    width = get_proplayer_flashvars('width',flashvars);
    height = get_proplayer_flashvars('height',flashvars);
    title = get_proplayer_flashvars('title',flashvars);

    //if image; do it
    if (image.length>0) {
      //build HTML
      image_tag='<a title="'+title+'" href="#'+container_id+'" rel="shadowbox;width='+width+';height='+height+'"><img class="proplayer_thumb" src="'+image+'"/></a>';
      //insert HTML
      container.before( image_tag );
    }
  });

  jQuery('.ajaxloading').removeClass('ajaxloading');

});

function get_proplayer_flashvars(param,flashvars) {
  flashvars_split = flashvars.split(param+'=');
  if (flashvars_split[1])
    flashvars_split2 = flashvars_split[1].split('&');

  if (flashvars_split2[0])
    return flashvars_split2[0];
}

style.css

1
2
3
4
5
6
7
8
9
10
(or use wp_enqueue_style if you want to have it in a separate file)

/*GALLERIES*/
img.proplayer_thumb{
  width:280px;
  height:157px;
}
.pro-player-container {
  display:none;
}