public function image_display($id)
    {
        global $WD_BWG_UPLOAD_DIR;
        $rows_data = $this->model->get_image_rows_data($id);
        $page_nav = $this->model->image_page_nav($id);
        $search_value = isset($_POST['search_value']) ? esc_html(stripslashes($_POST['search_value'])) : '';
        $asc_or_desc = isset($_POST['asc_or_desc']) ? esc_html(stripslashes($_POST['asc_or_desc'])) : 'asc';
        $image_order_by = isset($_POST['image_order_by']) ? esc_html(stripslashes($_POST['image_order_by'])) : 'order';
        $order_class = 'manage-column column-title sorted ' . $asc_or_desc;
        $page_number = isset($_POST['page_number']) ? esc_html(stripslashes($_POST['page_number'])) : 1;
        $ids_string = '';
        ?>
      <div id="draganddrop" class="updated" style="display:none;"><strong><p>Changes made in this table should be saved.</p></strong></div>
      <a style="margin: 5px 0;" href="<?php 
        echo add_query_arg(array('action' => 'addImages', 'width' => '700', 'height' => '550', 'extensions' => 'jpg,jpeg,png,gif', 'callback' => 'bwg_add_image', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
        ?>
" class="button-primary thickbox thickbox-preview" id="content-add_media" title="Add Images" onclick="return false;" style="margin-bottom:5px;">
        Add Images
      </a>
      <div class="buttons_div">
        <span class="button-secondary non_selectable" onclick="spider_check_all_items()">
          <input type="checkbox" id="check_all_items" name="check_all_items" onclick="spider_check_all_items_checkbox()" style="margin: 0; vertical-align: middle;" />
          <span style="vertical-align: middle;">Select All</span>
        </span>
        <input id="show_hide_weights"  class="button-secondary" type="button" onclick="spider_show_hide_weights();return false;" value="Hide order column" />
        <input class="button-primary" type="submit" onclick="spider_set_input_value('ajax_task', 'image_set_watermark');
                                                             spider_ajax_save('galleries_form');
                                                             return false;" value="Set Watermark" />
        <input class="button-secondary" type="submit" onclick="spider_set_input_value('ajax_task', 'image_recover_all');
                                                             spider_ajax_save('galleries_form');
                                                             return false;" value="Reset" />
        <input class="button-secondary" type="submit" onclick="spider_set_input_value('ajax_task', 'image_publish_all');
                                                     spider_ajax_save('galleries_form');
                                                     return false;" value="Publish" />
        <input class="button-secondary" type="submit" onclick="spider_set_input_value('ajax_task', 'image_unpublish_all');
                                                     spider_ajax_save('galleries_form');
                                                     return false;" value="Unpublish" />
        <input class="button-secondary" type="submit" onclick="if (confirm('Do you want to delete selected items?')) {
                                                       spider_set_input_value('ajax_task', 'image_delete_all');
                                                       spider_ajax_save('galleries_form');
                                                       return false;
                                                     } else {
                                                       return false;
                                                     }" value="Delete" />
      </div>
      <div class="tablenav top">
        <?php 
        WDWLibrary::ajax_search('Filename', $search_value, 'galleries_form');
        WDWLibrary::ajax_html_page_nav($page_nav['total'], $page_nav['limit'], 'galleries_form');
        ?>
      </div>

      <table id="images_table" class="wp-list-table widefat fixed pages">
        <thead>
          <th class="check-column table_small_col"></th>
          <th class="manage-column column-cb check-column table_small_col"><input id="check_all" type="checkbox" onclick="spider_check_all(this)" style="margin:0;" /></th>
          <th class="table_small_col">#</th>
          <th class="table_extra_large_col">Thumbnail</th>
          <th class="table_extra_large_col <?php 
        if ($image_order_by == 'filename') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'filename');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'filename' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Filename</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_extra_large_col <?php 
        if ($image_order_by == 'alt') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'alt');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'alt' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Alt/Title</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_extra_large_col <?php 
        if ($image_order_by == 'description') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'description');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'description' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Description</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_extra_large_col">Tags</th>
          <th id="th_order" class="table_medium_col <?php 
        if ($image_order_by == 'order') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'order');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'order' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Order</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_big_col <?php 
        if ($image_order_by == 'published') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'published');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'published' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Published</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_big_col">Delete</th>
        </thead>
        <tbody id="tbody_arr">
          <?php 
        $i = ($page_number - 1) * 20;
        if ($rows_data) {
            foreach ($rows_data as $row_data) {
                $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
                $rows_tag_data = $this->model->get_tag_rows_data($row_data->id);
                $published_image = $row_data->published ? 'publish' : 'unpublish';
                $published = $row_data->published ? 'unpublish' : 'publish';
                ?>
              <tr id="tr_<?php 
                echo $row_data->id;
                ?>
" <?php 
                echo $alternate;
                ?>
>
                <td class="connectedSortable table_small_col"><div title="Drag to re-order" class="handle" style="margin:5px auto 0 auto;"></div></td>
                <td class="table_small_col check-column"><input id="check_<?php 
                echo $row_data->id;
                ?>
" name="check_<?php 
                echo $row_data->id;
                ?>
" onclick="spider_check_all(this)" type="checkbox" /></td>
                <td class="table_small_col"><?php 
                echo ++$i;
                ?>
</td>
                <td class="table_extra_large_col">
                  <a class="thickbox thickbox-preview" title="<?php 
                echo $row_data->filename;
                ?>
" href="<?php 
                echo add_query_arg(array('action' => 'editThumb', 'type' => 'display', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
                ?>
">
                    <img id="image_thumb_<?php 
                echo $row_data->id;
                ?>
" class="thumb" src="<?php 
                echo site_url() . '/' . $WD_BWG_UPLOAD_DIR . $row_data->thumb_url . '?date=' . date('Y-m-y H:i:s');
                ?>
">
                  </a>
                </td>
                <td class="table_extra_large_col">
                  <div class="filename" id="filename_<?php 
                echo $row_data->id;
                ?>
">
                    <strong><a title="<?php 
                echo $row_data->filename;
                ?>
" class="spider_word_wrap thickbox thickbox-preview" href="<?php 
                echo add_query_arg(array('action' => 'editThumb', 'type' => 'display', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
                ?>
"><?php 
                echo $row_data->filename;
                ?>
</a></strong>
                  </div>
                  <div class="fileDescription" title="Date modified" id="date_modified_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo date("d F Y, H:i", strtotime($row_data->date));
                ?>
</div>
                  <div class="fileDescription" title="Image Resolution" id="fileresolution_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->resolution;
                ?>
</div>
                  <div class="fileDescription" title="Image size" id="filesize_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->size;
                ?>
</div>
                  <div class="fileDescription" title="Image type" id="filetype_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->filetype;
                ?>
</div>
                  <div>
                    <span class="edit_thumb"><a class="thickbox thickbox-preview" href="<?php 
                echo add_query_arg(array('action' => 'editThumb', 'type' => 'crop', 'image_id' => $row_data->id, 'TB_iframe' => '1', 'width' => '800', 'height' => '500'), admin_url('admin-ajax.php'));
                ?>
">Crop</a></span> | 
                    <span class="edit_thumb"><a class="thickbox thickbox-preview" href="<?php 
                echo add_query_arg(array('action' => 'editThumb', 'type' => 'rotate', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
                ?>
">Rotate</a></span> | 
                    <span class="edit_thumb"><a onclick="if (confirm('Do you want to reset the image?')) {
                                                          spider_set_input_value('ajax_task', 'recover');
                                                          spider_set_input_value('image_current_id', '<?php 
                echo $row_data->id;
                ?>
');
                                                          spider_ajax_save('galleries_form');
                                                         }
                                                         return false;">Reset</a></span>
                  </div>
                  <input type="hidden" id="image_url_<?php 
                echo $row_data->id;
                ?>
" name="image_url_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->image_url;
                ?>
" />
                  <input type="hidden" id="thumb_url_<?php 
                echo $row_data->id;
                ?>
" name="thumb_url_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->thumb_url;
                ?>
" />
                  <input type="hidden" id="input_filename_<?php 
                echo $row_data->id;
                ?>
" name="input_filename_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->filename;
                ?>
" />
                  <input type="hidden" id="input_date_modified_<?php 
                echo $row_data->id;
                ?>
" name="input_date_modified_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->date;
                ?>
" />
                  <input type="hidden" id="input_resolution_<?php 
                echo $row_data->id;
                ?>
" name="input_resolution_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->resolution;
                ?>
" />
                  <input type="hidden" id="input_size_<?php 
                echo $row_data->id;
                ?>
" name="input_size_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->size;
                ?>
" />
                  <input type="hidden" id="input_filetype_<?php 
                echo $row_data->id;
                ?>
" name="input_filetype_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->filetype;
                ?>
" />
                </td>
                <td class="table_extra_large_col">
                  <input size="24" type="text" id="image_alt_text_<?php 
                echo $row_data->id;
                ?>
" name="image_alt_text_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->alt;
                ?>
" />
                </td>
                <td class="table_extra_large_col">
                  <textarea cols="20" rows="2" id="image_description_<?php 
                echo $row_data->id;
                ?>
" name="image_description_<?php 
                echo $row_data->id;
                ?>
" style="resize:vertical;"><?php 
                echo $row_data->description;
                ?>
</textarea>
                </td>
                <td class="table_extra_large_col">
                  <a href="<?php 
                echo add_query_arg(array('action' => 'addTags', 'image_id' => $row_data->id, 'width' => '650', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
                ?>
" class="button button-small button-primary thickbox thickbox-preview">Add tag</a>
                  <div class="tags_div" id="tags_div_<?php 
                echo $row_data->id;
                ?>
">
                  <?php 
                $tags_id_string = '';
                if ($rows_tag_data) {
                    foreach ($rows_tag_data as $row_tag_data) {
                        ?>
                      <div class="tag_div" id="<?php 
                        echo $row_data->id;
                        ?>
_tag_<?php 
                        echo $row_tag_data->term_id;
                        ?>
">
                        <span class="tag_name"><?php 
                        echo $row_tag_data->name;
                        ?>
</span>
                        <span style="float:right;" class="spider_delete_img_small" onclick="bwg_remove_tag('<?php 
                        echo $row_tag_data->term_id;
                        ?>
', '<?php 
                        echo $row_data->id;
                        ?>
')" />
                      </div>
                      <?php 
                        $tags_id_string .= $row_tag_data->term_id . ',';
                    }
                }
                ?>
                  </div>
                  <input type="hidden" value="<?php 
                echo $tags_id_string;
                ?>
" id="tags_<?php 
                echo $row_data->id;
                ?>
" name="tags_<?php 
                echo $row_data->id;
                ?>
"/>
                </td>
                <td class="spider_order table_medium_col"><input id="order_input_<?php 
                echo $row_data->id;
                ?>
" name="order_input_<?php 
                echo $row_data->id;
                ?>
" type="text" size="1" value="<?php 
                echo $row_data->order;
                ?>
" /></td>
                <td class="table_big_col"><a onclick="spider_set_input_value('ajax_task', 'image_<?php 
                echo $published;
                ?>
');
                                                      spider_set_input_value('image_current_id', '<?php 
                echo $row_data->id;
                ?>
');
                                                      spider_ajax_save('galleries_form');"><img src="<?php 
                echo WD_BWG_URL . '/images/' . $published_image . '.png';
                ?>
"></img></a></td>
                <td class="table_big_col"><a onclick="spider_set_input_value('ajax_task', 'image_delete');
                                                      spider_set_input_value('image_current_id', '<?php 
                echo $row_data->id;
                ?>
');
                                                      spider_ajax_save('galleries_form');">Delete</a></td>
              </tr>
              <?php 
                $ids_string .= $row_data->id . ',';
            }
        }
        ?>
          <input id="ids_string" name="ids_string" type="hidden" value="<?php 
        echo $ids_string;
        ?>
" />
          <input id="asc_or_desc" name="asc_or_desc" type="hidden" value="asc" />
          <input id="image_order_by" name="image_order_by" type="hidden" value="<?php 
        echo $image_order_by;
        ?>
" />
          <input id="ajax_task" name="ajax_task" type="hidden" value="" />
          <input id="image_current_id" name="image_current_id" type="hidden" value="" />
        </tbody>
      </table>
      <script>
        window.onload = spider_show_hide_weights;
      </script>
    <?php 
    }
    public function image_display($id)
    {
        global $WD_BWG_UPLOAD_DIR;
        $rows_data = $this->model->get_image_rows_data($id);
        $page_nav = $this->model->image_page_nav($id);
        $option_row = $this->model->get_option_row_data();
        $search_value = isset($_POST['search_value']) ? esc_html(stripslashes($_POST['search_value'])) : '';
        $image_asc_or_desc = isset($_POST['image_asc_or_desc']) ? esc_html(stripslashes($_POST['image_asc_or_desc'])) : (isset($_COOKIE['bwg_image_asc_or_desc']) ? esc_html(stripslashes($_COOKIE['bwg_image_asc_or_desc'])) : 'asc');
        $image_order_by = isset($_POST['image_order_by']) ? esc_html(stripslashes($_POST['image_order_by'])) : (isset($_COOKIE['bwg_image_order_by']) ? esc_html(stripslashes($_COOKIE['bwg_image_order_by'])) : 'order');
        $order_class = 'manage-column column-title sorted ' . $image_asc_or_desc;
        $page_number = isset($_POST['page_number']) ? esc_html(stripslashes($_POST['page_number'])) : 1;
        $ids_string = '';
        $per_page = $this->model->per_page();
        $pager = 0;
        $gallery_row = $this->model->get_row_data($id);
        $gallery_type = $gallery_row->gallery_type == 'instagram' || $gallery_row->gallery_type == 'instagram_post' ? 'instagram' : '';
        $image_array = array('image_set_watermark' => __('Set Watermark', 'bwg_back'), 'image_get_resize' => __('Resize', 'bwg_back'), 'resize_image_thumb' => __('Recreate Thumbnail', 'bwg_back'), 'image_recover_all' => __('Reset', 'bwg_back'), 'image_publish_all' => __('Publish', 'bwg_back'), 'image_unpublish_all' => __('Unpublish', 'bwg_back'), 'image_desc' => __('Edit', 'bwg_back'), 'image_delete_all' => __('Delete', 'bwg_back'));
        ?>
    <div class="buttons_div_left">
      <?php 
        $query_url = add_query_arg(array('action' => 'addImages', 'width' => '700', 'height' => '550', 'extensions' => 'jpg,jpeg,png,gif', 'callback' => 'bwg_add_image'), admin_url('admin-ajax.php'));
        $query_url = wp_nonce_url($query_url, 'addImages', 'bwg_nonce');
        $query_url = add_query_arg(array('TB_iframe' => '1'), $query_url);
        ?>
      <a href="<?php 
        echo $query_url;
        ?>
" id="add_image_bwg" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-add thickbox thickbox-preview" id="content-add_media" title="<?php 
        _e("Add Images", 'bwg_back');
        ?>
" onclick="return false;" style="margin-bottom:5px; <?php 
        if ($gallery_type != '') {
            echo 'display:none';
        }
        ?>
" >
        <?php 
        _e('Add Images', 'bwg_back');
        ?>
      </a>
      <?php 
        $query_url = wp_nonce_url(admin_url('admin-ajax.php'), '', 'bwg_nonce');
        /*(re?)define ajax_url to add nonce only in admin*/
        ?>
      <script>
        var ajax_url = "<?php 
        echo $query_url;
        ?>
"
      </script>
        <input id="show_add_embed" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-media"  type="button" title="<?php 
        _e("Embed Media", 'bwg_back');
        ?>
" onclick="jQuery('.opacity_add_embed').show(); jQuery('#add_embed_help').hide(); return false;" value="<?php 
        _e("Embed Media", 'bwg_back');
        ?>
" />
        <input id="show_bulk_embed" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-bulk_media spider_free_version_button" type="button" title="<?php 
        _e("Social Bulk Embed", 'bwg_back');
        ?>
" onclick="jQuery('.opacity_bulk_embed').show(); return false;" value="<?php 
        _e("Social Bulk Embed", 'bwg_back');
        ?>
" />
        <?php 
        WDWLibrary::ajax_search(__('Filename', 'bwg_back'), $search_value, 'galleries_form');
        ?>
    </div>
    <div class="tablenav top buttons_div_left bwg_buttons_div">
      <span class="wd-btn wd-btn-primary-gray bwg_check_all  non_selectable " onclick="spider_check_all_items()">
        <input type="checkbox" id="check_all_items" name="check_all_items" onclick="spider_check_all_items_checkbox()" style="margin: 0; vertical-align: middle;" />
        <span style="vertical-align: middle;"><?php 
        echo __('Select All', 'bwg_back');
        ?>
</span>
      </span>
      <select class="select_icon bulk_action_img">
        <option value=""><?php 
        _e('Bulk Actions', 'bwg_back');
        ?>
</option>
        <?php 
        foreach ($image_array as $key => $value) {
            ?>
        <option value="<?php 
            echo $key;
            ?>
"><?php 
            echo $value;
            ?>
</option>
          <?php 
        }
        ?>
      </select>
      <input class="wd-btn wd-btn-primary wd-btn-icon wd-btn-apply" type="button" title="<?php 
        _e("Apply", "bwg_back");
        ?>
" onclick="if (!bwg_bulk_actions('.bulk_action_img', '')) {return false;}" value="<?php 
        _e("Apply", "bwg_back");
        ?>
" />
      <?php 
        WDWLibrary::ajax_html_page_nav($page_nav['total'], $page_nav['limit'], 'galleries_form', $per_page, $pager++);
        ?>
    </div>
    <div class="opacity_resize_image opacity_add_embed opacity_image_desc opacity_bulk_embed bwg_opacity_media" onclick="jQuery('.opacity_add_embed').hide(); jQuery('.opacity_bulk_embed').hide(); jQuery('.opacity_resize_image').hide(); jQuery('.opacity_image_desc').hide();"></div>       
      <div id="add_embed" class="opacity_add_embed bwg_add_embed">
        <input type="text" id="embed_url" name="embed_url" value="" />
        <input class="wd-btn wd-btn-primary wd-btn-icon wd-btn-add" type="button" onclick="if (bwg_get_embed_info('embed_url')) {jQuery('.opacity_add_embed').hide();} return false;" value="<?php 
        _e('Add to gallery', 'bwg_back');
        ?>
" />
        <input class="wd-btn wd-btn-primary wd-btn-icon wd-btn-cancel" type="button" onclick="jQuery('.opacity_add_embed').hide(); return false;" value="<?php 
        _e('Cancel', 'bwg_back');
        ?>
" />
        <div class="spider_description">
        <p><?php 
        _e('Enter YouTube, Vimeo, Instagram, Flickr or Dailymotion URL here.', 'bwg_back');
        ?>
 <a onclick="jQuery('#add_embed_help').show();" style='text-decoration: underline; color:blue; cursor: pointer;'><?php 
        _e('Help', 'bwg_back');
        ?>
</a></p>
        </div>
        <div id="add_embed_help" class="opacity_add_embed bwg_add_embed" style="display: none;">
          <p style="text-align:right; margin-top:0px;"><a onclick="jQuery('#add_embed_help').hide();" style="text-decoration: underline; color:blue; cursor: pointer; "><?php 
        _e('Close', 'bwg_back');
        ?>
</a></p>
          <p><b>Youtube</b> <?php 
        _e('URL example:', 'bwg_back');
        ?>
 <i>https://www.youtube.com/watch?v=fa4RLjE-yM8</i></p>
          <p><b>Vimeo</b> <?php 
        _e('URL example:', 'bwg_back');
        ?>
 <i>http://vimeo.com/8110647</i></p>
          <p><b>Instagram</b> <?php 
        _e('URL example:', 'bwg_back');
        ?>
 <i>http://instagram.com/p/ykvv0puS4u</i>. <?php 
        _e('Add', 'bwg_back');
        ?>
 "<i style="text-decoration:underline;"><?php 
        _e('post', 'bwg_back');
        ?>
</i>" <?php 
        _e('to the end of URL if you want to embed the whole Instagram post, not only its content.', 'bwg_back');
        ?>
</p>
          <p><b>Flickr</b> <?php 
        _e('URL example:', 'bwg_back');
        ?>
 <i>https://www.flickr.com/photos/sui-fong/15250186998/in/gallery-flickr-72157648726328108/</i></p>
          <p><b>Dailymotion</b> <?php 
        _e('URL example:', 'bwg_back');
        ?>
 <i>http://www.dailymotion.com/video/xexaq0_frank-sinatra-strangers-in-the-nigh_music</i></p>
        </div>
      </div>
      <div id="bulk_embed" class="opacity_bulk_embed bwg_bulk_embed">
        <input class="wd-btn wd-btn-primary wd-btn-icon wd-btn-cancel" type="button" onclick="jQuery('.opacity_bulk_embed').hide(); jQuery('#opacity_div').hide(); jQuery('#loading_div').hide(); return false;" value="<?php 
        _e('Cancel', 'bwg_back');
        ?>
" style="float: right; margin-left: 5px;" />
        <input class="wd-btn wd-btn-primary wd-btn-icon wd-btn-add spider_free_version_button" type="button" value="<?php 
        _e('Add to gallery', 'bwg_back');
        ?>
" style="float:right; margin-left:5px;"/>
        <div class="spider_description"></div>
        <table class="spider_free_version ">
          <thead>
            <tr>
              <td class="spider_label_galleries"><label for="bulk_embed_from" class="spider_free_version_label_color"><?php 
        _e("Bulk embed from:", 'bwg_back');
        ?>
 </label></td>
              <td>
                <input type="radio" disabled="disabled" class="inputbox" id="bulk_embed_from_instagram" onclick="jQuery('#instagram_bulk_params').show();" checked="checked" value="<?php 
        _e("instagram", 'bwg_back');
        ?>
" >
                <label for="bulk_embed_from_instagram" class="spider_free_version_label_color"><?php 
        _e("Instagram", 'bwg_back');
        ?>
</label>&nbsp;
              </td>
            </tr>
          </thead>
          <tbody id="instagram_bulk_params">
            <tr id='popup_tr_instagram_gallery_source' style='display:table-row'>
              <td class="spider_label_galleries"><label for="popup_instagram_gallery_source" class="spider_free_version_label_color"><?php 
        _e("Instagram username:"******"spider_free_version_label_color"><input type="text" id="popup_instagram_gallery_source" disabled="disabled" value="<?php 
        _e("Bulk embed from Instagram is disabled in free version", 'bwg_back');
        ?>
" size="64" /></td>
            </tr>
            <tr id='popup_tr_instagram_image_number' style='display:table-row'>
              <td class="spider_label_galleries"><label for="popup_instagram_image_number" class="spider_free_version_label_color"><?php 
        _e("Number of Instagram recent posts to add to gallery:", 'bwg_back');
        ?>
 </label></td>
              <td><input type="number" disabled="disabled" id="popup_instagram_image_number" value="12" /></td>
            </tr>
            <tr id='popup_tr_instagram_post_gallery' style='display:table-row'>
              <td class="spider_label_galleries"><label class="spider_free_version_label_color"><?php 
        _e("Instagram embed type:", 'bwg_back');
        ?>
 </label></td>
              <td class="spider_free_version_label_color">
                <input type="radio" disabled="disabled" class="inputbox" id="popup_instagram_post_gallery_0" checked="checked" value="0" >
                <label for="popup_instagram_post_gallery_0" class="spider_free_version_label_color"><?php 
        _e("Content", 'bwg_back');
        ?>
</label>&nbsp;
                <input type="radio" disabled="disabled" class="inputbox" id="popup_instagram_post_gallery_1" value="1" >
                <label for="popup_instagram_post_gallery_1" class="spider_free_version_label_color"><?php 
        _e("Whole post", 'bwg_back');
        ?>
</label>
              </td>
            </tr>
          </tbody>
       </table>
      </div>
      <div class="opacity_resize_image bwg_resize_image">
        <?php 
        _e("Resize images to: ", 'bwg_back');
        ?>
        <input type="text" name="image_width" id="image_width" value="1600" /> x 
        <input type="text" name="image_height" id="image_height" value="1200" /> px
        <input class="wd-btn wd-btn-primary wd-not-image" type="button" onclick="spider_set_input_value('ajax_task', 'image_resize');
                                                                                 spider_ajax_save('galleries_form');
                                                                                 jQuery('.opacity_resize_image').hide();
                                                                                 return false;" value="<?php 
        _e("Resize", 'bwg_back');
        ?>
" />
        <input class="wd-btn wd-btn-primary wd-btn-icon wd-btn-cancel" type="button" onclick="jQuery('.opacity_resize_image').hide(); return false;" value="<?php 
        _e("Cancel", 'bwg_back');
        ?>
" />
        <div class="spider_description"><?php 
        _e("The maximum size of resized image.", 'bwg_back');
        ?>
</div>
      </div>
      <div id="add_desc" class="opacity_image_desc bwg_image_desc">
        <div>
          <span class="bwg_popup_label">
            <?php 
        _e('Alt/Title: ', 'bwg_back');
        ?>
          </span>
          <input class="bwg_popup_input" type="text" id="title" name="title" value="" />
          <input class="wd-btn wd-btn-primary wd-btn-icon wd-btn-add" type="button" onclick="if (window.parent.bwg_add_title_desc()) {jQuery('.opacity_image_desc').hide();} return false;" value="<?php 
        echo __('Update', 'bwg_back');
        ?>
" />
          <input class="wd-btn wd-btn-primary wd-btn-icon wd-btn-cancel" type="button" onclick="jQuery('.opacity_image_desc').hide(); return false;" value="<?php 
        echo __('Cancel', 'bwg_back');
        ?>
" />
        </div>
        <?php 
        if ($option_row->thumb_click_action != 'open_lightbox') {
            ?>
        <div>
          <span class="bwg_popup_label">
            <?php 
            _e('Redirect URL: ', 'bwg_back');
            ?>
          </span>
          <input class="bwg_popup_input" type="text" id="redirecturl" name="redirecturl" value="" />
        </div>
        <?php 
        }
        ?>
        <div>
          <span class="bwg_popup_label">
            <?php 
        _e('Description: ', 'bwg_back');
        ?>
          </span>
          <textarea class="bwg_popup_input" type="text" id="desc" name="desc"></textarea>
        </div>
      </div>
      <div id="draganddrop" class="wd_updated" style="display:none;"><strong><p><?php 
        _e('Changes made in this table should be saved.', 'bwg_back');
        ?>
</p></strong></div>
      <table id="images_table" class="wp-list-table widefat fixed pages">
        <thead>
         <th class="check-column table_small_col table_medium_col manage-column column-title sorted asc" style="margin: 0px auto 0px 15px; width: 60px; vertical-align: middle;">
            <a id="show_hide_weights" class="bwg_order_column" title="<?php 
        _e('Hide order column', 'bwg_back');
        ?>
" onclick="spider_show_hide_weights();return false;" value="<?php 
        _e('Hide order column', 'bwg_back');
        ?>
"></a>
            <a id="th_order" onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'order');
                        spider_set_input_value('image_asc_or_desc', 'desc');
                        spider_ajax_save('galleries_form');" style="display: none;">
             <span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="manage-column column-cb check-column table_small_col" style="padding-top:12px !important;"><input id="check_all" type="checkbox" onclick="spider_check_all(this)" style="margin:5px auto 0;" />
          
          </th>
          <th class="table_small_col">#</th>
          <th class="table_extra_large_col"><?php 
        _e('Thumbnail', 'bwg_back');
        ?>
</th>
          <th class="sortable table_extra_large_col <?php 
        if ($image_order_by == 'filename') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'filename');
                        spider_set_input_value('image_asc_or_desc', '<?php 
        echo $image_order_by == 'filename' && $image_asc_or_desc == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span><?php 
        _e('Filename', 'bwg_back');
        ?>
</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="sortable table_extra_large_col <?php 
        if ($image_order_by == 'alt') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'alt');
                        spider_set_input_value('image_asc_or_desc', '<?php 
        echo $image_order_by == 'alt' && $image_asc_or_desc == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span><?php 
        _e('Alt/Title', 'bwg_back');
        if ($option_row->thumb_click_action != 'open_lightbox') {
            ?>
<br /><?php 
            echo __('Redirect', 'bwg_back');
            ?>
 URL<?php 
        }
        ?>
</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="sortable table_extra_large_col <?php 
        if ($image_order_by == 'description') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'description');
                        spider_set_input_value('image_asc_or_desc', '<?php 
        echo $image_order_by == 'description' && $image_asc_or_desc == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span><?php 
        _e('Description', 'bwg_back');
        ?>
</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <?php 
        $query_url = wp_nonce_url(admin_url('admin-ajax.php'), 'addTags', 'bwg_nonce');
        $query_url = add_query_arg(array('action' => 'addTags', 'width' => '650', 'height' => '500', 'bwg_items_per_page' => $per_page), $query_url);
        ?>
          <th class="table_extra_big_col">
            <a onclick="return bwg_check_checkboxes();"  title="<?php 
        echo __('Add tag', 'bwg_back');
        ?>
" href="<?php 
        echo $query_url;
        ?>
&TB_iframe=1" class="wd-btn wd-btn-primary wd-not-image thickbox thickbox-preview"><?php 
        echo __('Add tag', 'bwg_back');
        ?>
</a>
          </th>
          <th class="sortable table_big_col <?php 
        if ($image_order_by == 'published') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'published');
                        spider_set_input_value('image_asc_or_desc', '<?php 
        echo $image_order_by == 'published' && $image_asc_or_desc == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span><?php 
        _e('Published', 'bwg_back');
        ?>
</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_small_col"><?php 
        echo __('Delete', 'bwg_back');
        ?>
</th>
        </thead>
        <tbody id="tbody_arr">
          <?php 
        $i = ($page_number - 1) * $per_page;
        if ($rows_data) {
            foreach ($rows_data as $row_data) {
                $is_embed = preg_match('/EMBED/', $row_data->filetype) == 1 ? true : false;
                $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
                $rows_tag_data = $this->model->get_tag_rows_data($row_data->id);
                $published_image = $row_data->published ? 'publish-blue' : 'unpublish-red';
                $published = $row_data->published ? 'unpublish' : 'publish';
                $unpublish = !$row_data->published ? 'Unpublish' : 'Publish';
                ?>
              <tr id="tr_<?php 
                echo $row_data->id;
                ?>
" <?php 
                echo $alternate;
                ?>
>
                <td class="spider_order table_medium_col"><input id="order_input_<?php 
                echo $row_data->id;
                ?>
" name="order_input_<?php 
                echo $row_data->id;
                ?>
" type="text" size="1" value="<?php 
                echo $row_data->order;
                ?>
" /></td>
                <td class="connectedSortable handles table_small_col"><div title="Drag to re-order" class="handle" style="margin:5px auto 0 auto;"></div></td>
                <td class="table_small_col check-column"><input id="check_<?php 
                echo $row_data->id;
                ?>
" name="check_<?php 
                echo $row_data->id;
                ?>
" onclick="spider_check_all(this)" type="checkbox" /></td>
                <td class="table_small_col"><?php 
                echo ++$i;
                ?>
</td>
                <td class="table_extra_large_col">
                <?php 
                $is_embed_instagram_post = preg_match('/INSTAGRAM_POST/', $row_data->filetype) == 1 ? true : false;
                $instagram_post_width = 0;
                $instagram_post_height = 0;
                if ($is_embed_instagram_post) {
                    $image_resolution = explode(' x ', $row_data->resolution);
                    if (is_array($image_resolution)) {
                        $instagram_post_width = $image_resolution[0];
                        $instagram_post_height = explode(' ', $image_resolution[1]);
                        $instagram_post_height = $instagram_post_height[0];
                    }
                }
                $query_url = add_query_arg(array('action' => 'editThumb', 'type' => 'display', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500', 'instagram_post_width' => $instagram_post_width, 'instagram_post_height' => $instagram_post_height), admin_url('admin-ajax.php'));
                $query_url = wp_nonce_url($query_url, 'editThumb', 'bwg_nonce');
                $query_url = add_query_arg(array('TB_iframe' => '1'), $query_url);
                $is_embed_instagram_post = preg_match('/INSTAGRAM_POST/', $row_data->filetype) == 1 ? true : false;
                ?>
                  <a class="thickbox thickbox-preview" title="<?php 
                echo $row_data->alt;
                ?>
" href="<?php 
                echo $query_url;
                ?>
">
                    <img id="image_thumb_<?php 
                echo $row_data->id;
                ?>
" class="thumb" src="<?php 
                echo (!$is_embed ? site_url() . '/' . $WD_BWG_UPLOAD_DIR : "") . $row_data->thumb_url . ($is_embed ? '' : '?date=' . date('Y-m-y H:i:s'));
                ?>
" />
                  </a>
                </td>
                <td class="table_extra_large_col">
                  <div class="filename" id="filename_<?php 
                echo $row_data->id;
                ?>
">
                    <strong><a title="<?php 
                echo $row_data->alt;
                ?>
" class="spider_word_wrap thickbox thickbox-preview" href="<?php 
                echo $query_url;
                ?>
"><?php 
                echo $row_data->filename;
                ?>
</a></strong>
                  </div>
                  <div class="fileDescription" title="<?php 
                _e("Date modified", 'bwg_back');
                ?>
" id="date_modified_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo date("d F Y, H:i", strtotime($row_data->date));
                ?>
</div>
                  <div class="fileDescription" title="<?php 
                _e("Image Resolution", 'bwg_back');
                ?>
" id="fileresolution_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->resolution;
                ?>
</div>
                  <div class="fileDescription" title="<?php 
                _e("Image size", 'bwg_back');
                ?>
" id="filesize_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->size;
                ?>
</div>
                  <div class="fileDescription" title="<?php 
                _e("Type", 'bwg_back');
                ?>
" id="filetype_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->filetype;
                ?>
</div>
                  <?php 
                if (!$is_embed) {
                    ?>
                  <div> 
                    <?php 
                    $query_url = add_query_arg(array('action' => 'editThumb', 'type' => 'crop', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500'), admin_url('admin-ajax.php'));
                    $query_url = wp_nonce_url($query_url, 'editThumb', 'bwg_nonce');
                    $query_url = add_query_arg(array('TB_iframe' => '1'), $query_url);
                    ?>
                    <span class="edit_thumb"><a class="thickbox thickbox-preview" href="<?php 
                    echo $query_url;
                    ?>
"><?php 
                    _e("Crop", 'bwg_back');
                    ?>
</a></span> | 
                    <?php 
                    $query_url = add_query_arg(array('action' => 'editThumb', 'type' => 'rotate', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500'), admin_url('admin-ajax.php'));
                    $query_url = wp_nonce_url($query_url, 'editThumb', 'bwg_nonce');
                    $query_url = add_query_arg(array('TB_iframe' => '1'), $query_url);
                    ?>
                    <span class="edit_thumb"><a class="thickbox thickbox-preview" href="<?php 
                    echo $query_url;
                    ?>
"><?php 
                    _e("Edit", 'bwg_back');
                    ?>
</a></span> | 
                    <span class="edit_thumb"><a onclick="if (confirm('<?php 
                    echo addslashes(__('Do you want to reset the image?', 'bwg_back'));
                    ?>
')) {
                                                          spider_set_input_value('ajax_task', 'recover');
                                                          spider_set_input_value('image_current_id', '<?php 
                    echo $row_data->id;
                    ?>
');
                                                          spider_ajax_save('galleries_form');
                                                         }
                                                         return false;"><?php 
                    _e('Reset', 'bwg_back');
                    ?>
</a></span>
                  </div>
                  <?php 
                }
                ?>
                  <input type="hidden" id="image_url_<?php 
                echo $row_data->id;
                ?>
" name="image_url_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->image_url;
                ?>
" />
                  <input type="hidden" id="thumb_url_<?php 
                echo $row_data->id;
                ?>
" name="thumb_url_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->thumb_url;
                ?>
" />
                  <input type="hidden" id="input_filename_<?php 
                echo $row_data->id;
                ?>
" name="input_filename_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->filename;
                ?>
" />
                  <input type="hidden" id="input_date_modified_<?php 
                echo $row_data->id;
                ?>
" name="input_date_modified_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->date;
                ?>
" />
                  <input type="hidden" id="input_resolution_<?php 
                echo $row_data->id;
                ?>
" name="input_resolution_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->resolution;
                ?>
" />
                  <input type="hidden" id="input_size_<?php 
                echo $row_data->id;
                ?>
" name="input_size_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->size;
                ?>
" />
                  <input type="hidden" id="input_filetype_<?php 
                echo $row_data->id;
                ?>
" name="input_filetype_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->filetype;
                ?>
" />
                </td>
                <td class="table_extra_large_col">
                  <textarea rows="2" id="image_alt_text_<?php 
                echo $row_data->id;
                ?>
" name="image_alt_text_<?php 
                echo $row_data->id;
                ?>
" style="resize:vertical;"><?php 
                echo $row_data->alt;
                ?>
</textarea>
                  <?php 
                if ($option_row->thumb_click_action != 'open_lightbox') {
                    ?>
                  <input size="24" type="text" id="redirect_url_<?php 
                    echo $row_data->id;
                    ?>
" name="redirect_url_<?php 
                    echo $row_data->id;
                    ?>
" value="<?php 
                    echo $row_data->redirect_url;
                    ?>
" />
                  <?php 
                }
                ?>
                </td>
                <td class="table_extra_large_col">
                  <textarea rows="3" id="image_description_<?php 
                echo $row_data->id;
                ?>
" name="image_description_<?php 
                echo $row_data->id;
                ?>
" style="resize:vertical;"><?php 
                echo $row_data->description;
                ?>
</textarea>
                </td>
                <td class="table_extra_large_col">
                  <?php 
                $query_url = wp_nonce_url(admin_url('admin-ajax.php'), 'addTags', 'bwg_nonce');
                $query_url = add_query_arg(array('action' => 'addTags', 'image_id' => $row_data->id, 'width' => '650', 'height' => '500', 'bwg_items_per_page' => $per_page, 'TB_iframe' => '1'), $query_url);
                ?>
                  <a href="<?php 
                echo $query_url;
                ?>
" title="<?php 
                _e('Add tag', 'bwg_back');
                ?>
" class="button-small wd-btn wd-btn-primary wd-not-image thickbox thickbox-preview"><?php 
                _e('Add tag', 'bwg_back');
                ?>
</a>
                  <div class="tags_div" id="tags_div_<?php 
                echo $row_data->id;
                ?>
">
                  <?php 
                $tags_id_string = '';
                if ($rows_tag_data) {
                    foreach ($rows_tag_data as $row_tag_data) {
                        ?>
                      <div class="tag_div" id="<?php 
                        echo $row_data->id;
                        ?>
_tag_<?php 
                        echo $row_tag_data->term_id;
                        ?>
">
                        <span class="tag_name"><?php 
                        echo $row_tag_data->name;
                        ?>
</span>
                        <span style="float:right;" class="spider_delete_img_small" onclick="bwg_remove_tag('<?php 
                        echo $row_tag_data->term_id;
                        ?>
', '<?php 
                        echo $row_data->id;
                        ?>
')" />
                      </div>
                      <?php 
                        $tags_id_string .= $row_tag_data->term_id . ',';
                    }
                }
                ?>
                  </div>
                  <input type="hidden" value="<?php 
                echo $tags_id_string;
                ?>
" id="tags_<?php 
                echo $row_data->id;
                ?>
" name="tags_<?php 
                echo $row_data->id;
                ?>
"/>
                </td>
                <td class="table_big_col publish_icon"><a style="background-image:url('<?php 
                echo WD_BWG_URL . '/images/icons/' . $published_image . '.png';
                ?>
'); background-repeat: no-repeat; display: inline-block; width: 18px; height: 22px;margin: 3px; vertical-align: middle;background-size: contain;" title="<?php 
                echo $unpublish;
                ?>
" onclick="spider_set_input_value('ajax_task', 'image_<?php 
                echo $published;
                ?>
');
                                                      spider_set_input_value('image_current_id', '<?php 
                echo $row_data->id;
                ?>
');
                                                      spider_ajax_save('galleries_form');"></a></td>
                <td class="table_big_col spider_delete_button" ><a class="bwg_img_remove" title='<?php 
                echo __('Delete', 'bwg_back');
                ?>
' onclick="if (confirm('<?php 
                echo addslashes(__('Do you want to delete selected items?', 'bwg_back'));
                ?>
')) {
                                                      spider_set_input_value('ajax_task', 'image_delete');
                                                      spider_set_input_value('image_current_id', '<?php 
                echo $row_data->id;
                ?>
');
                                                      spider_ajax_save('galleries_form');
                                                      } else {
                                                       return false;
                                                      }"></a></td>
              </tr>
              <?php 
                $ids_string .= $row_data->id . ',';
            }
        }
        ?>
          <input id="ids_string" name="ids_string" type="hidden" value="<?php 
        echo $ids_string;
        ?>
" />
          <input id="asc_or_desc" name="asc_or_desc" type="hidden" value="asc" />
          <input id="image_asc_or_desc" name="image_asc_or_desc" type="hidden" value="asc" />
          <input id="image_order_by" name="image_order_by" type="hidden" value="<?php 
        echo $image_order_by;
        ?>
" />
          <input id="ajax_task" name="ajax_task" type="hidden" value="" />
          <input id="image_current_id" name="image_current_id" type="hidden" value="" />
          <input id="added_tags_select_all" name="added_tags_select_all" type="hidden" value="" />
          <input type="hidden" id="bulk_edit" name="bulk_edit" value="0" />
        </tbody>
      </table>
      <div class="tablenav bottom">
        <?php 
        WDWLibrary::ajax_html_page_nav($page_nav['total'], $page_nav['limit'], 'galleries_form', $per_page, $pager++);
        ?>
      </div>
      <script>
        window.onload = spider_show_hide_weights;
      </script>
    <?php 
    }
    public function image_display($id)
    {
        global $WD_BWG_UPLOAD_DIR;
        $rows_data = $this->model->get_image_rows_data($id);
        $page_nav = $this->model->image_page_nav($id);
        $option_row = $this->model->get_option_row_data();
        $search_value = isset($_POST['search_value']) ? esc_html(stripslashes($_POST['search_value'])) : '';
        $asc_or_desc = isset($_POST['asc_or_desc']) ? esc_html(stripslashes($_POST['asc_or_desc'])) : 'asc';
        $image_order_by = isset($_POST['image_order_by']) ? esc_html(stripslashes($_POST['image_order_by'])) : 'order';
        $order_class = 'manage-column column-title sorted ' . $asc_or_desc;
        $page_number = isset($_POST['page_number']) ? esc_html(stripslashes($_POST['page_number'])) : 1;
        $ids_string = '';
        $per_page = $this->model->per_page();
        $gallery_row = $this->model->get_row_data($id);
        $gallery_type = $gallery_row->gallery_type == 'instagram' || $gallery_row->gallery_type == 'instagram_post' ? 'instagram' : '';
        $pager = 0;
        ?>
      <div id="draganddrop" class="updated" style="display:none;"><strong><p>Changes made in this table should be saved.</p></strong></div>
      <div class="buttons_div_left">
        <?php 
        $query_url = add_query_arg(array('action' => 'addImages', 'width' => '700', 'height' => '550', 'extensions' => 'jpg,jpeg,png,gif', 'callback' => 'bwg_add_image'), admin_url('admin-ajax.php'));
        $query_url = wp_nonce_url($query_url, 'addImages', 'bwg_nonce');
        $query_url = add_query_arg(array('TB_iframe' => '1'), $query_url);
        ?>
        <a href="<?php 
        echo $query_url;
        ?>
" class="button-primary thickbox thickbox-preview" id="content-add_media" title="Add Images" onclick="return false;" style="margin-bottom:5px; <?php 
        if ($gallery_type != '') {
            echo 'display:none';
        }
        ?>
" >
          Add Images
        </a>
        <?php 
        $query_url = wp_nonce_url(admin_url('admin-ajax.php'), '', 'bwg_nonce');
        /*(re?)define ajax_url to add nonce only in admin*/
        ?>
        <script>
          var ajax_url = "<?php 
        echo $query_url;
        ?>
"
        </script>
        <input id="show_add_embed" class="button-primary"  type="button" onclick="jQuery('.opacity_add_embed').show(); jQuery('#add_embed_help').hide(); return false;" value="Embed Media" />
        <input id="show_bulk_embed" class="button-primary spider_free_version_button" type="button" onclick="jQuery('.opacity_bulk_embed').show(); return false;" value="Bulk Embed" />
      </div>
      <div class="buttons_div_right">
        <span class="button-secondary non_selectable" onclick="spider_check_all_items()">
          <input type="checkbox" id="check_all_items" name="check_all_items" onclick="spider_check_all_items_checkbox()" style="margin: 0; vertical-align: middle;" />
          <span style="vertical-align: middle;">Select All</span>
        </span>
        <input id="show_hide_weights"  class="button-secondary" type="button" onclick="spider_show_hide_weights();return false;" value="Hide order column" />
        <input class="button-primary" id='spider_setwatermark_button' type="submit" onclick="spider_set_input_value('ajax_task', 'image_set_watermark');
                                                             spider_ajax_save('galleries_form');
                                                             return false;" value="Set Watermark" />
        <input class="button-secondary" id='spider_resize_button' type="submit" onclick="jQuery('.opacity_resize_image').show(); return false;" value="Resize" />
	<input class="button-secondary" type="submit" onclick="spider_set_input_value('ajax_task', 'resize_image_thumb'); spider_ajax_save('galleries_form');return false;" value="Recreate Thumbnail" />
        <input class="button-secondary" id='spider_reset_button' type="submit" onclick="spider_set_input_value('ajax_task', 'image_recover_all');
                                                             spider_ajax_save('galleries_form');
                                                             return false;" value="Reset" />
        <?php 
        $query_url = wp_nonce_url(admin_url('admin-ajax.php'), 'addTags', 'bwg_nonce');
        $query_url = add_query_arg(array('action' => 'addTags', 'width' => '650', 'height' => '500', 'bwg_items_per_page' => $per_page), $query_url);
        ?>
                                                             
        <a onclick="return bwg_check_checkboxes();" href="<?php 
        echo $query_url;
        ?>
&TB_iframe=1" class="button-primary thickbox thickbox-preview">Add tag</a>
  

        <input class="button-secondary" type="submit" onclick="spider_set_input_value('ajax_task', 'image_publish_all');
                                                     spider_ajax_save('galleries_form');
                                                     return false;" value="Publish" />
        <input class="button-secondary" type="submit" onclick="spider_set_input_value('ajax_task', 'image_unpublish_all');
                                                     spider_ajax_save('galleries_form');
                                                     return false;" value="Unpublish" />
                <input class="button-secondary spider_delete_button" type="submit" onclick="if (confirm('Do you want to delete selected items?')) {
                                                       spider_set_input_value('ajax_task', 'image_delete_all');
                                                       spider_ajax_save('galleries_form');
                                                       return false;
                                                     } else {
                                                       return false;
                                                     }" value="Delete" />
      </div>
      <div class="opacity_resize_image opacity_add_embed opacity_bulk_embed bwg_opacity_media" onclick="jQuery('.opacity_add_embed').hide(); jQuery('.opacity_bulk_embed').hide(); jQuery('.opacity_resize_image').hide();"></div>
      <div id="add_embed" class="opacity_add_embed bwg_add_embed">
        <input type="text" id="embed_url" name="embed_url" value="" />
        <input class="button-primary" type="button" onclick="if (bwg_get_embed_info('embed_url')) {jQuery('.opacity_add_embed').hide();} return false;" value="Add to gallery" />
        <input class="button-secondary" type="button" onclick="jQuery('.opacity_add_embed').hide(); return false;" value="Cancel" />
        <div class="spider_description">
        <p>Enter YouTube, Vimeo, Instagram, Flickr or Dailymotion URL here. <a onclick="jQuery('#add_embed_help').show();" style='text-decoration: underline; color:blue; cursor: pointer;'>Help</a></p>
        </div>
        <div id='add_embed_help' class= "opacity_add_embed bwg_add_embed" style="display:none;">
          <p style="text-align:right; margin-top:0px;"><a onclick="jQuery('#add_embed_help').hide();" style="text-decoration: underline; color:blue; cursor: pointer; ">Close</a></p>
          <p><b>Youtube</b> URL example: <i style="">https://www.youtube.com/watch?v=fa4RLjE-yM8</i></p>
          <p><b>Vimeo</b> URL example: <i style="">http://vimeo.com/8110647</i></p>
          <p><b>Instagram</b> URL example: <i style="">http://instagram.com/p/ykvv0puS4u</i>. Add "<i style="text-decoration:underline;">post</i>" to the end of URL if you want to embed the whole Instagram post, not only its content.</p>
          <p><b>Flickr</b> URL example: <i style="">https://www.flickr.com/photos/sui-fong/15250186998/in/gallery-flickr-72157648726328108/</i></p>
          <p><b>Dailymotion</b> URL example: <i style="">http://www.dailymotion.com/video/xexaq0_frank-sinatra-strangers-in-the-nigh_music</i></p>
        </div>
      </div>
      <div id="bulk_embed" class="opacity_bulk_embed bwg_bulk_embed">
        <input class="button-secondary" type="button" onclick="jQuery('.opacity_bulk_embed').hide(); jQuery('#opacity_div').hide(); jQuery('#loading_div').hide(); return false;" value="Cancel" style="float:right; margin-left:5px;"/>
        <input class="button-primary spider_free_version_button" type="button" value="Add to gallery" style="float:right; margin-left:5px;"/>
        <div class="spider_description"></div>
       <table class="spider_free_version">
         <thead>
           <tr>
              <td class="spider_label_galleries"><label for="bulk_embed_from" class="spider_free_version_label">Bulk embed from: </label></td>
              <td>
                <input type="radio" disabled="disabled" class="inputbox" id="bulk_embed_from_instagram" onclick="jQuery('#instagram_bulk_params').show();" checked="checked" value="instagram" >
                <label for="bulk_embed_from_instagram" class="spider_free_version_label">Instagram</label>&nbsp;
              </td>
            </tr>
          </thead>
          <tbody id="instagram_bulk_params">
            <tr id='popup_tr_instagram_gallery_source' style='display:table-row'>
              <td class="spider_label_galleries"><label for="popup_instagram_gallery_source" class="spider_free_version_label">Instagram username: </label></td>
              <td class="spider_free_version_label"><input type="text" id="popup_instagram_gallery_source" disabled="disabled" value="Bulk embed from Instagram is disabled in free version" size="64" /></td>
            </tr>
            <tr id='popup_tr_instagram_image_number' style='display:table-row'>
              <td class="spider_label_galleries"><label for="popup_instagram_image_number" class="spider_free_version_label">Number of Instagram recent posts to add to gallery: </label></td>
              <td><input type="number" disabled="disabled" id="popup_instagram_image_number" value="12" /></td>
            </tr>
            <tr id='popup_tr_instagram_post_gallery' style='display:table-row'>
              <td class="spider_label_galleries"><label class="spider_free_version_label">Instagram embed type: </label></td>
              <td class="spider_free_version_label">
                <input type="radio" disabled="disabled" class="inputbox" id="popup_instagram_post_gallery_0" checked="checked" value="0" >
                <label for="popup_instagram_post_gallery_0" class="spider_free_version_label">Content</label>&nbsp;
                <input type="radio" disabled="disabled" class="inputbox" id="popup_instagram_post_gallery_1" value="1" >
                <label for="popup_instagram_post_gallery_1" class="spider_free_version_label">Whole post</label>
              </td>
            <tr>
         </tbody>
       </table>
      

      </div>
      <div id="" class="opacity_resize_image bwg_resize_image">
        Resize images to: 
        <input type="text" name="image_width" id="image_width" value="1600" /> x 
        <input type="text" name="image_height" id="image_height" value="1200" /> px
        <input class="button-primary" type="button" onclick="spider_set_input_value('ajax_task', 'image_resize');
                                                             spider_ajax_save('galleries_form');
                                                             jQuery('.opacity_resize_image').hide();
                                                             return false;" value="Resize" />
        <input class="button-secondary" type="button" onclick="jQuery('.opacity_resize_image').hide(); return false;" value="Cancel" />
        <div class="spider_description">The maximum size of resized image.</div>
      </div>
      <div class="tablenav top">
        <?php 
        WDWLibrary::ajax_search('Filename', $search_value, 'galleries_form');
        WDWLibrary::ajax_html_page_nav($page_nav['total'], $page_nav['limit'], 'galleries_form', $per_page, $pager++);
        ?>
      </div>

      <table id="images_table" class="wp-list-table widefat fixed pages">
        <thead>
          <th class="check-column table_small_col"></th>
          <th class="manage-column column-cb check-column table_small_col"><input id="check_all" type="checkbox" onclick="spider_check_all(this)" style="margin:0;" /></th>
          <th class="table_small_col">#</th>
          <th class="table_extra_large_col">Thumbnail</th>
          <th class="table_extra_large_col <?php 
        if ($image_order_by == 'filename') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'filename');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'filename' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Filename</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_extra_large_col <?php 
        if ($image_order_by == 'alt') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'alt');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'alt' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Alt/Title<?php 
        if ($option_row->thumb_click_action != 'open_lightbox') {
            ?>
<br />Redirect URL<?php 
        }
        ?>
</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_extra_large_col <?php 
        if ($image_order_by == 'description') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'description');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'description' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Description</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_extra_large_col">Tags</th>
          <th id="th_order" class="table_medium_col <?php 
        if ($image_order_by == 'order') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'order');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'order' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Order</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_big_col <?php 
        if ($image_order_by == 'published') {
            echo $order_class;
        }
        ?>
">
            <a onclick="spider_set_input_value('task', '');
                        spider_set_input_value('image_order_by', 'published');
                        spider_set_input_value('asc_or_desc', '<?php 
        echo isset($_POST['asc_or_desc']) && isset($_POST['image_order_by']) && esc_html(stripslashes($_POST['image_order_by'])) == 'published' && esc_html(stripslashes($_POST['asc_or_desc'])) == 'asc' ? 'desc' : 'asc';
        ?>
');
                        spider_ajax_save('galleries_form');">
              <span>Published</span><span class="sorting-indicator"></span>
            </a>
          </th>
          <th class="table_big_col">Delete</th>
        </thead>
        <tbody id="tbody_arr">
          <?php 
        $i = ($page_number - 1) * $per_page;
        if ($rows_data) {
            foreach ($rows_data as $row_data) {
                $is_embed = preg_match('/EMBED/', $row_data->filetype) == 1 ? true : false;
                $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
                $rows_tag_data = $this->model->get_tag_rows_data($row_data->id);
                $published_image = $row_data->published ? 'publish' : 'unpublish';
                $published = $row_data->published ? 'unpublish' : 'publish';
                ?>
              <tr id="tr_<?php 
                echo $row_data->id;
                ?>
" <?php 
                echo $alternate;
                ?>
>
                <td class="connectedSortable table_small_col"><div title="Drag to re-order" class="handle" style="margin:5px auto 0 auto;"></div></td>
                <td class="table_small_col check-column"><input id="check_<?php 
                echo $row_data->id;
                ?>
" name="check_<?php 
                echo $row_data->id;
                ?>
" onclick="spider_check_all(this)" type="checkbox" /></td>
                <td class="table_small_col"><?php 
                echo ++$i;
                ?>
</td>
                <td class="table_extra_large_col">
                  <?php 
                $query_url = add_query_arg(array('action' => 'editThumb', 'type' => 'display', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500'), admin_url('admin-ajax.php'));
                $query_url = wp_nonce_url($query_url, 'editThumb', 'bwg_nonce');
                $query_url = add_query_arg(array('TB_iframe' => '1'), $query_url);
                ?>
                  <a class="thickbox thickbox-preview" title="<?php 
                echo $row_data->alt;
                ?>
" href="<?php 
                echo $query_url;
                ?>
">
                    <img id="image_thumb_<?php 
                echo $row_data->id;
                ?>
" class="thumb" src="<?php 
                echo (!$is_embed ? site_url() . '/' . $WD_BWG_UPLOAD_DIR : "") . $row_data->thumb_url . '?date=' . date('Y-m-y H:i:s');
                ?>
">
                  </a>
                </td>
                <td class="table_extra_large_col">
                  <div class="filename" id="filename_<?php 
                echo $row_data->id;
                ?>
">
                    <strong><a title="<?php 
                echo $row_data->alt;
                ?>
" class="spider_word_wrap thickbox thickbox-preview" href="<?php 
                echo $query_url;
                ?>
"><?php 
                echo $row_data->filename;
                ?>
</a></strong>
                  </div>
                  <div class="fileDescription" title="Date modified" id="date_modified_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo date("d F Y, H:i", strtotime($row_data->date));
                ?>
</div>
                  <div class="fileDescription" title="Image Resolution" id="fileresolution_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->resolution;
                ?>
</div>
                  <div class="fileDescription" title="Image size" id="filesize_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->size;
                ?>
</div>
                  <div class="fileDescription" title="Type" id="filetype_<?php 
                echo $row_data->id;
                ?>
"><?php 
                echo $row_data->filetype;
                ?>
</div>
                  <?php 
                if (!$is_embed) {
                    ?>
                  <div> 
                    <?php 
                    $query_url = add_query_arg(array('action' => 'editThumb', 'type' => 'crop', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500'), admin_url('admin-ajax.php'));
                    $query_url = wp_nonce_url($query_url, 'editThumb', 'bwg_nonce');
                    $query_url = add_query_arg(array('TB_iframe' => '1'), $query_url);
                    ?>
                    <span class="edit_thumb"><a class="thickbox thickbox-preview" href="<?php 
                    echo $query_url;
                    ?>
">Crop</a></span> | 
                    <?php 
                    $query_url = add_query_arg(array('action' => 'editThumb', 'type' => 'rotate', 'image_id' => $row_data->id, 'width' => '800', 'height' => '500'), admin_url('admin-ajax.php'));
                    $query_url = wp_nonce_url($query_url, 'editThumb', 'bwg_nonce');
                    $query_url = add_query_arg(array('TB_iframe' => '1'), $query_url);
                    ?>
                    <span class="edit_thumb"><a class="thickbox thickbox-preview" href="<?php 
                    echo $query_url;
                    ?>
">Rotate</a></span> | 
                    <span class="edit_thumb"><a onclick="if (confirm('Do you want to reset the image?')) {
                                                          spider_set_input_value('ajax_task', 'recover');
                                                          spider_set_input_value('image_current_id', '<?php 
                    echo $row_data->id;
                    ?>
');
                                                          spider_ajax_save('galleries_form');
                                                         }
                                                         return false;">Reset</a></span>
                  </div>
                  <?php 
                }
                ?>
                  <input type="hidden" id="image_url_<?php 
                echo $row_data->id;
                ?>
" name="image_url_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->image_url;
                ?>
" />
                  <input type="hidden" id="thumb_url_<?php 
                echo $row_data->id;
                ?>
" name="thumb_url_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->thumb_url;
                ?>
" />
                  <input type="hidden" id="input_filename_<?php 
                echo $row_data->id;
                ?>
" name="input_filename_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->filename;
                ?>
" />
                  <input type="hidden" id="input_date_modified_<?php 
                echo $row_data->id;
                ?>
" name="input_date_modified_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->date;
                ?>
" />
                  <input type="hidden" id="input_resolution_<?php 
                echo $row_data->id;
                ?>
" name="input_resolution_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->resolution;
                ?>
" />
                  <input type="hidden" id="input_size_<?php 
                echo $row_data->id;
                ?>
" name="input_size_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->size;
                ?>
" />
                  <input type="hidden" id="input_filetype_<?php 
                echo $row_data->id;
                ?>
" name="input_filetype_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->filetype;
                ?>
" />
                </td>
                <td class="table_extra_large_col">
                  <input size="24" type="text" id="image_alt_text_<?php 
                echo $row_data->id;
                ?>
" name="image_alt_text_<?php 
                echo $row_data->id;
                ?>
" value="<?php 
                echo $row_data->alt;
                ?>
 " />
                  <?php 
                if ($option_row->thumb_click_action != 'open_lightbox') {
                    ?>
                  <input size="24" type="text" id="redirect_url_<?php 
                    echo $row_data->id;
                    ?>
" name="redirect_url_<?php 
                    echo $row_data->id;
                    ?>
" value="<?php 
                    echo $row_data->redirect_url;
                    ?>
" />
                  <?php 
                }
                ?>
                </td>
                <td class="table_extra_large_col">
                  <textarea cols="20" rows="2" id="image_description_<?php 
                echo $row_data->id;
                ?>
" name="image_description_<?php 
                echo $row_data->id;
                ?>
" style="resize:vertical;"><?php 
                echo $row_data->description;
                ?>
</textarea>
                </td>
                <td class="table_extra_large_col">
                  <?php 
                $query_url = wp_nonce_url(admin_url('admin-ajax.php'), 'addTags', 'bwg_nonce');
                $query_url = add_query_arg(array('action' => 'addTags', 'image_id' => $row_data->id, 'width' => '650', 'height' => '500', 'bwg_items_per_page' => $per_page, 'TB_iframe' => '1'), $query_url);
                ?>
                  <a href="<?php 
                echo $query_url;
                ?>
" class="button button-small button-primary thickbox thickbox-preview">Add tag</a>
                  <div class="tags_div" id="tags_div_<?php 
                echo $row_data->id;
                ?>
">
                  <?php 
                $tags_id_string = '';
                if ($rows_tag_data) {
                    foreach ($rows_tag_data as $row_tag_data) {
                        ?>
                      <div class="tag_div" id="<?php 
                        echo $row_data->id;
                        ?>
_tag_<?php 
                        echo $row_tag_data->term_id;
                        ?>
">
                        <span class="tag_name"><?php 
                        echo $row_tag_data->name;
                        ?>
</span>
                        <span style="float:right;" class="spider_delete_img_small" onclick="bwg_remove_tag('<?php 
                        echo $row_tag_data->term_id;
                        ?>
', '<?php 
                        echo $row_data->id;
                        ?>
')" />
                      </div>
                      <?php 
                        $tags_id_string .= $row_tag_data->term_id . ',';
                    }
                }
                ?>
                  </div>
                  <input type="hidden" value="<?php 
                echo $tags_id_string;
                ?>
" id="tags_<?php 
                echo $row_data->id;
                ?>
" name="tags_<?php 
                echo $row_data->id;
                ?>
"/>
                </td>
                <td class="spider_order table_medium_col"><input id="order_input_<?php 
                echo $row_data->id;
                ?>
" name="order_input_<?php 
                echo $row_data->id;
                ?>
" type="text" size="1" value="<?php 
                echo $row_data->order;
                ?>
" /></td>
                <td class="table_big_col"><a onclick="spider_set_input_value('ajax_task', 'image_<?php 
                echo $published;
                ?>
');
                                                      spider_set_input_value('image_current_id', '<?php 
                echo $row_data->id;
                ?>
');
                                                      spider_ajax_save('galleries_form');"><img src="<?php 
                echo WD_BWG_URL . '/images/' . $published_image . '.png';
                ?>
"></img></a></td>
                <td class="table_big_col spider_delete_button" ><a onclick="spider_set_input_value('ajax_task', 'image_delete');
                                                      spider_set_input_value('image_current_id', '<?php 
                echo $row_data->id;
                ?>
');
                                                      spider_ajax_save('galleries_form');">Delete</a></td>
              </tr>
              <?php 
                $ids_string .= $row_data->id . ',';
            }
        }
        ?>
          <input id="ids_string" name="ids_string" type="hidden" value="<?php 
        echo $ids_string;
        ?>
" />
          <input id="asc_or_desc" name="asc_or_desc" type="hidden" value="asc" />
          <input id="image_order_by" name="image_order_by" type="hidden" value="<?php 
        echo $image_order_by;
        ?>
" />
          <input id="ajax_task" name="ajax_task" type="hidden" value="" />
          <input id="image_current_id" name="image_current_id" type="hidden" value="" />
          <input id="added_tags_select_all" name="added_tags_select_all" type="hidden" value="" />
        </tbody>
      </table>
      <div class="tablenav bottom">
        <?php 
        WDWLibrary::ajax_html_page_nav($page_nav['total'], $page_nav['limit'], 'galleries_form', $per_page, $pager++);
        ?>
      </div>
      <script>
        window.onload = spider_show_hide_weights;
      </script>
    <?php 
    }