function gmedia_add_media_library() { global $user_ID, $gmCore, $gmDB, $gmGallery; wp_enqueue_style('gmedia-bootstrap'); wp_enqueue_script('gmedia-bootstrap'); wp_enqueue_style('grand-media'); wp_enqueue_script('grand-media'); $post_id = intval($gmCore->_get('post_id')); if (current_user_can('gmedia_show_others_media')) { $author = 0; } else { $author = $user_ID; } $args = array('mime_type' => $gmCore->_get('mime_type', 'image/*'), 'author' => $author, 'orderby' => 'ID', 'order' => 'DESC', 'per_page' => 50, 'page' => $gmCore->_get('pager', 1), 's' => $gmCore->_get('s', null)); $gmediaQuery = $gmDB->get_gmedias($args); ?> <div class="panel panel-default" id="gmedia-container"> <div class="panel-heading clearfix"> <?php include GMEDIA_ABSPATH . 'admin/tpl/search-form.php'; ?> <div class="pull-right"> <?php echo $gmDB->query_pager(); ?> </div> </div> <div class="panel-body" id="gm-list-table"> <div class="row"> <div class="col-xs-7 col-md-9" style="text-align:justify;white-space:normal;"> <?php if (count($gmediaQuery)) { foreach ($gmediaQuery as $item) { gmedia_item_more_data($item); ?> <form class="thumbnail" id="list-item-<?php echo $item->ID; ?> " data-id="<?php echo $item->ID; ?> " data-type="<?php echo $item->type; ?> "> <img src="<?php echo $gmCore->gm_get_media_image($item, 'thumb'); ?> " style="height:100px;width:auto;" alt=""/> <span class="glyphicon glyphicon-ok text-success"></span> <div class="media-upload-form" style="display:none;"> <input name="ID" type="hidden" value="<?php echo $item->ID; ?> "/> <div class="form-group"> <label><?php _e('Title', 'grand-media'); ?> </label> <input name="title" type="text" class="form-control input-sm" placeholder="<?php _e('Title', 'grand-media'); ?> " value="<?php esc_attr_e($item->title); ?> "> </div> <div class="form-group"> <label><?php _e('Link To', 'grand-media'); ?> </label> <select id="gmedia_url" class="form-control input-sm" style="display:block;margin-bottom:5px;"> <option value="customurl" selected="selected"><?php _e('Custom URL'); ?> </option> <option value="weburl"><?php _e('Web size image'); ?> </option> <?php if ($item->path_original) { ?> <option value="originalurl"><?php _e('Original image'); ?> </option> <?php } ?> </select> <input name="link" type="text" class="customurl form-control input-sm" value="<?php echo $item->link; ?> " placeholder="http://"/> <input name="link" type="text" style="display:none;font-size:80%;" readonly="readonly" disabled="disabled" class="weburl form-control input-sm" value="<?php echo $item->url_web; ?> "/> <?php if ($item->path_original) { ?> <input name="link" type="text" style="display:none;font-size:80%;" readonly="readonly" disabled="disabled" class="originalurl form-control input-sm" value="<?php echo $item->url_original; ?> "/> <?php } ?> </div> <div class="form-group"> <label><?php _e('Description', 'grand-media'); ?> </label> <textarea name="description" class="form-control input-sm" rows="4" cols="10"><?php echo esc_textarea($item->description); ?> </textarea> </div> <?php if ('image' == $item->type) { $_metadata = $item->meta['_metadata'][0]; ?> <div class="form-group"> <label><?php _e('Size', 'grand-media'); ?> </label> <select name="size" class="form-control input-sm"> <option value="thumb"><?php echo 'Thumb - ' . $_metadata['thumb']['width'] . ' × ' . $_metadata['thumb']['height']; ?> </option> <option value="web" selected="selected"><?php echo 'Web - ' . $_metadata['web']['width'] . ' × ' . $_metadata['web']['height']; ?> </option> <?php if ($item->path_original) { ?> <option value="original"><?php echo 'Original - ' . $_metadata['original']['width'] . ' × ' . $_metadata['original']['height']; ?> </option> <?php } ?> </select> </div> <?php } ?> <div class="form-group"> <label><?php _e('Alignment', 'grand-media'); ?> </label> <select name="align" class="form-control input-sm"> <option value="none" selected="selected"><?php _e('None', 'grand-media'); ?> </option> <option value="left"><?php _e('Left', 'grand-media'); ?> </option> <option value="center"><?php _e('Center', 'grand-media'); ?> </option> <option value="right"><?php _e('Right', 'grand-media'); ?> </option> </select> </div> </div> </form> <?php } } else { ?> <div class="list-group-item"> <div class="well well-lg text-center"> <h4><?php _e('No items to show.', 'grand-media'); ?> </h4> <?php if ($gmCore->caps['gmedia_upload']) { ?> <p> <a target="_blank" href="<?php echo admin_url('admin.php?page=GrandMedia_AddMedia'); ?> " class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> <?php _e('Add Media', 'grand-media'); ?> </a></p> <?php } ?> </div> </div> <?php } ?> </div> <div class="col-xs-5 col-md-3 media-upload-sidebar"> <form method="post" id="gmedia-form" role="form"> <div id="media-upload-form-container" class="media-upload-form-container"></div> <div class="panel-footer"> <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?> "/> <?php wp_nonce_field('media-form'); ?> <button type="submit" id="media-upload-form-submit" disabled class="btn btn-primary pull-right" name="gmedia_library_insert"><?php _e('Insert into post', 'grand-media'); ?> </button> <?php if ($post_id && current_theme_supports('post-thumbnails', get_post_type($post_id))) { ?> <a id="gmedia-post-thumbnail" class="btn disabled" href="javascript:void(0);"><?php _e('Use as featured image', 'grand-media'); ?> </a> <?php } ?> </div> </form> </div> </div> </div> <!--suppress JSUnresolvedVariable --> <script type="text/javascript"> jQuery(function($) { function divFrame() { $('.panel-body').css({top: $('.panel-heading').outerHeight()}); } divFrame(); $(window).on('resize', function() { divFrame(); }); $('.thumbnail').on('click', function() { var form = $('#media-upload-form-container'); var but = $('.panel-footer .btn'); if($(this).hasClass('active')) { $(this).removeClass('active'); form.empty(); but.prop('disabled', true).addClass('disabled'); return; } $(this).addClass('active').siblings().removeClass('active'); form.html($('.media-upload-form', this).html()); but.prop('disabled', false).removeClass('disabled'); }); $('#gmedia-form').on('change', '#gmedia_url', function() { var val = $(this).val(); $(this).nextAll('input.' + val).show().prop('disabled', false).siblings('input').hide().prop('disabled', true); }); <?php if ($post_id && current_theme_supports('post-thumbnails', get_post_type($post_id))) { $featured_nonce = wp_create_nonce("set_post_thumbnail-{$post_id}"); ?> $('#gmedia-post-thumbnail').on('click', function() { if($(this).hasClass('disabled')) { return false; } var id = $('form.active').data('id'); $.post(ajaxurl, { action: "gmedia_set_post_thumbnail", post_id: '<?php echo $post_id; ?> ', img_id: id, _wpnonce: '<?php echo $featured_nonce; ?> ' }, function(str) { var win = window.dialogArguments || opener || parent || top; if(str == '0') { alert(win.setPostThumbnailL10n.error); } else if(str == '-1') { // image removed } else { win.WPSetThumbnailID(id); win.WPSetThumbnailHTML(str); } $('#__gm-uploader', win.document).css('display', 'none'); } ); }); <?php } ?> }); </script> </div> <?php }
function gmedia_update_data() { global $gmDB, $gmCore; check_ajax_referer("GmediaGallery"); if (!current_user_can('gmedia_edit_media')) { die('-1'); } $data = $gmCore->_post('data'); wp_parse_str($data, $gmedia); if (!empty($gmedia['ID'])) { $item = $gmDB->get_gmedia($gmedia['ID']); if ((int) $item->author != get_current_user_id()) { if (!current_user_can('gmedia_edit_others_media')) { die('-2'); } } $gmedia['modified'] = current_time('mysql'); $gmedia['mime_type'] = $item->mime_type; $gmedia['gmuid'] = $item->gmuid; if (!current_user_can('gmedia_delete_others_media')) { $gmedia['author'] = $item->author; } $gmuid = pathinfo($item->gmuid); $gmedia['filename'] = preg_replace('/[^a-z0-9_\\.-]+/i', '_', $gmedia['filename']); if ($gmedia['filename'] != $gmuid['filename'] && (current_user_can('gmedia_delete_others_media') || (int) $item->author == get_current_user_id())) { $fileinfo = $gmCore->fileinfo($gmedia['filename'] . '.' . $gmuid['extension']); if (false !== $fileinfo) { if ('image' == $fileinfo['dirname'] && file_is_displayable_image($fileinfo['dirpath'] . '/' . $item->gmuid)) { if (is_file($fileinfo['dirpath_original'] . '/' . $item->gmuid)) { @rename($fileinfo['dirpath_original'] . '/' . $item->gmuid, $fileinfo['filepath_original']); } @rename($fileinfo['dirpath_thumb'] . '/' . $item->gmuid, $fileinfo['filepath_thumb']); } if (@rename($fileinfo['dirpath'] . '/' . $item->gmuid, $fileinfo['filepath'])) { $gmedia['gmuid'] = $fileinfo['basename']; } } } if (!current_user_can('gmedia_terms')) { unset($gmedia['terms']); } $id = $gmDB->insert_gmedia($gmedia); if (!is_wp_error($id)) { // Meta Stuff if (isset($gmedia['meta']) && is_array($gmedia['meta'])) { $meta_error = array(); foreach ($gmedia['meta'] as $key => $value) { if ($gmCore->is_digit($key)) { $mid = (int) $key; //$value = wp_unslash( $value ); if (!($meta = $gmDB->get_metadata_by_mid('gmedia', $mid))) { $meta_error[] = array('error' => 'no_meta', 'message' => __('No record in DataBase.', 'grand-media'), 'meta_id' => $mid, 'meta_key' => $meta->meta_key); continue; } if ('' == trim($value)) { $meta_error[] = array('error' => 'empty_value', 'message' => __('Please provide a custom field value.', 'grand-media'), 'meta_id' => $mid, 'meta_key' => $meta->meta_key, 'meta_value' => $meta->meta_value); continue; } if ($meta->meta_value != $value) { if (!($u = $gmDB->update_metadata_by_mid('gmedia', $mid, $value))) { $meta_error[] = array('error' => 'meta_update', 'message' => __('Something goes wrong.', 'grand-media'), 'meta_id' => $mid, 'meta_key' => $meta->meta_key, 'meta_value' => $meta->meta_value); } } } elseif ('_' == $key[0]) { if ('_cover' == $key) { $value = ltrim($value, '#'); } elseif ('_gps' == $key) { if ($value) { $latlng = explode(',', $value); $value = array('lat' => trim($latlng[0]), 'lng' => trim($latlng[1])); } } $value = apply_filters('gmedia_protected_meta_value', $value, $key, $id); $gmDB->update_metadata('gmedia', $id, $key, $value); } } } $result = $gmDB->get_gmedia($id); } else { $result = $gmDB->get_gmedia($id); } gmedia_item_more_data($result); if ('image' != $result->type) { $result->thumbnail = gmedia_item_thumbnail($result); } if (current_user_can('gmedia_terms')) { if (!empty($gmedia['terms']['gmedia_album'])) { if (isset($gmedia['gmedia_album_order'])) { $album = $gmDB->get_the_gmedia_terms($id, 'gmedia_album'); if ($album) { $album = reset($album); if ((int) $gmedia['gmedia_album_order'] != (int) $album->gmedia_order) { $gmDB->update_term_sortorder($album->term_id, array($id => (int) $gmedia['gmedia_album_order'])); $result->gmedia_album_order = (int) $gmedia['gmedia_album_order']; } } } $alb_id = $gmedia['terms']['gmedia_album']; $alb = $gmDB->get_term($alb_id, 'gmedia_album'); $result->album_status = $alb ? $alb->status : 'none'; } else { $result->album_status = 'none'; } } if (!empty($meta_error)) { $result->meta_error = $meta_error; } header('Content-Type: application/json; charset=' . get_option('blog_charset'), true); echo json_encode($result); } die; }
/** * Gmedia Comments */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly require_once ABSPATH . 'wp-admin/includes/meta-boxes.php'; wp_enqueue_script('post'); wp_enqueue_script('admin-comments'); global $gmDB, $gmCore, $gmGallery, $post; $gmedia_id = $gmCore->_get('gmedia_id'); $gmedia_term_id = $gmCore->_get('gmedia_term_id'); if ($gmedia_id) { $gmedia = $gmDB->get_gmedia($gmedia_id); gmedia_item_more_data($gmedia); $post_id = $gmedia->post_id; } elseif ($gmedia_term_id) { $gmedia_term = $gmDB->get_term($gmedia_term_id); gmedia_term_item_more_data($gmedia_term); $post_id = $gmedia_term->post_id; } else { die('-1'); } $post = get_post($post_id); ?> <div id="commentsdiv" style="padding:1px 0;"> <style type="text/css" scoped> #commentsdiv {padding-top:1px;} #commentsdiv > .thumbnail {float:left; margin:0 10px 10px;} #commentsdiv > .thumbnail img.gmedia-thumb {max-height:72px;}
/** * @param $content * * @return mixed|string */ function gmedia_post_type__the_content($content) { global $post, $gmDB, $gmCore; if (isset($post->gmedia_content)) { $post->post_content = $post->gmedia_content; return $post->gmedia_content; } remove_filter('the_content', 'gmedia_post_type__the_content', 200); $output = ''; if ($post->post_type == 'gmedia') { $gmedia_id = get_post_meta($post->ID, '_gmedia_ID', true); $gmedia = $gmDB->get_gmedia($gmedia_id); if ($gmedia) { gmedia_item_more_data($gmedia); ob_start(); if ($gmedia->link) { $gmedia_link = $gmedia->link; $base_url_host = parse_url($gmCore->upload['url'], PHP_URL_HOST); $url_host = parse_url($gmedia->link, PHP_URL_HOST); if ($url_host == $base_url_host || empty($url_host)) { $link_target = ' target="_self"'; } else { $link_target = ' target="_blank"'; } if (isset($gmedia->meta['link_target'][0])) { $link_target = ' target="' . $gmedia->meta['link_target'][0] . '"'; } } else { $gmedia_link = $gmedia->url; $link_target = ''; } if ('image' == $gmedia->type) { ?> <a class="gmedia-item-link" href="<?php echo $gmedia_link; ?> "<?php echo $link_target; ?> ><img class="gmedia-item" style="max-width:100%;" src="<?php echo $gmedia->url; ?> " alt="<?php esc_attr_e($gmedia->title); ?> "/></a> <?php if (is_single()) { /** more info */ $author_name = get_the_author_meta('display_name', $gmedia->author); $author_posts_link = get_author_posts_url($gmedia->author); $avatar_img = get_avatar($gmedia->author, 60); if (preg_match("/src=['\"](.*?)['\"]/i", $avatar_img, $matches)) { $author_avatar = $matches[1]; } ?> <div class="gmsingle_wrapper gmsingle_clearfix"> <div class="gmsingle_photo_header gmsingle_clearfix"> <div class="gmsingle_name_wrap gmsingle_clearfix"> <?php if (!empty($author_avatar)) { ?> <div class="gmsingle_user_avatar"> <a class="gmsingle_user_avatar_link" href="<?php echo urldecode($author_posts_link); ?> "><img src="<?php echo $author_avatar; ?> " alt=""/></a> </div> <?php } ?> <div class="gmsingle_title_author"> <div class="gmsingle_title"><?php if ('image' != $gmedia->type && $gmedia->link) { echo "<a href='{$gmedia_link}'{$link_target}>{$gmedia->title} 🔗</a>"; } else { echo $gmedia->title; } ?> </div> <div class="gmsingle_author_name"> <a class="gmsingle_author_link" href="<?php echo urldecode($author_posts_link); ?> "><?php echo $author_name; ?> </a> </div> </div> </div> </div> <div class="gmsingle_photo_info"> <div class="gmsingle_description_wrap"> <?php echo apply_filters('the_gmedia_content', wpautop($gmedia->description)); if (!empty($gmedia->album)) { $term_name = $gmedia->album[0]->name; $term_post_id = $gmDB->get_metadata('gmedia_term', $gmedia->album[0]->term_id, '_post_ID', true); if (!empty($term_post_id)) { $term_url = get_permalink($term_post_id); } else { $term_url = $gmCore->gmcloudlink($gmedia->album[0]->term_id, 'album'); } ?> <div class="gmsingle_terms"> <span class="gmsingle_term_label"><?php _e('Album'); ?> :</span> <span class="gmsingle_album"><span class="gmsingle_term"><a href="<?php echo $term_url; ?> "><?php echo $term_name; ?> </a></span></span> </div> <?php } if (!empty($gmedia->categories)) { $item_cats = array(); foreach ($gmedia->categories as $term) { $term->slug = $term->name; $term_url = get_term_link($term); //$term_url = $gmCore->gmcloudlink($term->term_id, 'category'); $item_cats[] = "<span class='gmsingle_term'><a href='{$term_url}'>{$term->name}</a></span>"; } ?> <div class="gmsingle_terms"> <span class="gmsingle_term_label"><?php _e('Categories'); ?> :</span> <span class="gmsingle_categories"><?php echo implode(' ', $item_cats); ?> </span> </div> <?php } if (!empty($gmedia->tags)) { $item_tags = array(); foreach ($gmedia->tags as $term) { $term->slug = $term->name; $term_url = get_term_link($term); //$term_url = $gmCore->gmcloudlink($term->term_id, 'tag'); $item_tags[] = "<span class='gmsingle_term'><a href='{$term_url}'>#{$term->name}</a></span>"; } ?> <div class="gmsingle_terms"> <span class="gmsingle_term_label"><?php _e('Tags'); ?> :</span> <span class="gmsingle_tags"><?php echo implode(' ', $item_tags); ?> </span> </div> <?php } ?> </div> <?php if ($gmedia->gps) { $loc = str_replace(' ', '', $gmedia->gps); ?> <div class="gmsingle_location_section"> <div class="gmsingle_details_title"><?php _e('Location'); ?> </div> <div class="gmsingle_location_info"> <a href='https://www.google.com/maps/place/<?php echo $loc; ?> ' target='_blank'><img src='//maps.googleapis.com/maps/api/staticmap?key=AIzaSyBMiF6nlG5O1tE81Q-35_dckOwW4ypMRuk&size=320x240&zoom=10&scale=2&maptype=roadmap&markers=<?php echo $loc; ?> ' alt='' width='320' height='240'/></a> </div> </div> <?php } ?> <div class="gmsingle_details_section"> <div class="gmsingle_details_title"><?php _e('Details', 'grand-media'); ?> </div> <div class="gmsingle_slide_details"> <?php /* ?> <div class='gmsingle_badges'> <div class='gmsingle_badges__column'> <div class='gmsingle_badges__label'><?php _e('Views', 'grand-media'); ?></div> <div class='gmsingle_badges__count'><?php echo $gmedia->meta['views'][0]; ?></div> </div> <div class='gmsingle_badges__column'> <div class='gmsingle_badges__label'><?php _e('Likes', 'grand-media'); ?></div> <div class='gmsingle_badges__count gmsingle_like_count'><?php echo $gmedia->meta['likes'][0]; ?></div> </div> <div class='gmsingle_clearfix'></div> </div> <?php */ $exif = $gmCore->metadata_info($gmedia->ID); $details = array(); if (!empty($exif)) { $details['model'] = empty($exif['model']) ? '' : $exif['model']['value']; $details['lens'] = empty($exif['lens']) ? '' : $exif['lens']['value']; $details['camera_settings'] = array('focallength' => empty($exif['focallength']) ? empty($exif['focallength35']) ? '' : $exif['focallength35']['value'] : $exif['focallength']['value'], 'aperture' => empty($exif['aperture']) ? '' : str_replace('f', 'ƒ', $exif['aperture']['value']), 'exposure' => empty($exif['exposure']) ? '' : $exif['exposure']['value'], 'iso' => empty($exif['iso']) ? '' : 'ISO ' . $exif['iso']['value']); $details['camera_settings'] = array_filter($details['camera_settings']); $details['taken'] = empty($exif['created_timestamp']) ? '' : date_i18n(get_option('date_format'), $exif['created_timestamp']['value']); } $details['uploaded'] = date_i18n(get_option('date_format'), strtotime($gmedia->date)); if (!empty($details['model'])) { ?> <div class='gmsingle_exif'> <div class='gmsingle_label gmsingle_exif_model'><?php echo $details['model']; ?> </div> <?php if (!empty($details['lens'])) { ?> <div class='gmsingle_label_small gmsingle_exif_lens'><?php echo $details['lens']; ?> </div> <?php } $camera_settings = array(); foreach ($details['camera_settings'] as $key => $value) { $camera_settings[] = "<span class='gmsingle_exif_{$key}'>{$value}</span>"; } if (!empty($camera_settings)) { ?> <div class='gmsingle_label_small gmsingle_camera_settings'><?php echo implode('<span class="gmsingle_separator"> / </span>', $camera_settings); ?> </div> <?php } ?> </div> <?php } ?> <div class='gmsingle_meta'> <?php if (!empty($details['taken'])) { ?> <div class='gmsingle_clearfix'> <span class='gmsingle_meta_key'><?php _e('Created', 'grand-media'); ?> </span> <span class='gmsingle_meta_value'><?php echo $details['taken']; ?> </span> </div> <?php } ?> <div class='gmsingle_clearfix'> <span class='gmsingle_meta_key'><?php _e('Uploaded', 'grand-media'); ?> </span> <span class='gmsingle_meta_value'><?php echo $details['uploaded']; ?> </span> </div> </div> </div> </div> </div> </div> <style type="text/css"> .gmsingle_clearfix { display:block; } .gmsingle_clearfix::after { visibility:hidden; display:block; font-size:0; content:' '; clear:both; height:0; } .gmsingle_wrapper { margin:0 auto; } .gmsingle_wrapper * { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; } .gmsingle_photo_header { margin-bottom:15px; } .gmsingle_name_wrap { padding:24px 0 2px 80px; height:85px; max-width:100%; overflow:hidden; white-space:nowrap; position:relative; } .gmsingle_name_wrap .gmsingle_user_avatar { position:absolute; top:20px; left:0; } .gmsingle_name_wrap .gmsingle_user_avatar a.gmsingle_user_avatar_link { display:block; text-decoration:none; } .gmsingle_name_wrap .gmsingle_user_avatar img { height:60px; width:auto; overflow:hidden; border-radius:3px; } .gmsingle_name_wrap .gmsingle_title_author { display:inline-block; vertical-align:top; max-width:100%; } .gmsingle_name_wrap .gmsingle_title_author .gmsingle_title { text-rendering:auto; font-weight:100; font-size:24px; width:100%; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; margin:0; padding:1px 0; height:1.1em; line-height:1; box-sizing:content-box; text-transform:none; letter-spacing:0px; text-transform:capitalize; } .gmsingle_name_wrap .gmsingle_title_author > div { font-size:14px; } .gmsingle_name_wrap .gmsingle_title_author .gmsingle_author_name { float:left; } .gmsingle_name_wrap .gmsingle_title_author a { font-size:inherit; } .gmsingle_photo_info { display:flex; flex-wrap:wrap; } .gmsingle_details_title { margin:0; padding:0; text-transform:uppercase; font-size:18px; line-height:1em; font-weight:300; height:1.1em; display:inline-block; overflow:visible; border:none; } .gmsingle_description_wrap { flex:1; overflow:hidden; min-width:220px; max-width:100%; padding-right:7px; margin-bottom:30px; } .gmsingle_description_wrap .gmsingle_terms { overflow:hidden; margin:0; position:relative; font-size:14px; font-weight:300; } .gmsingle_description_wrap .gmsingle_term_label { margin-right:10px; } .gmsingle_description_wrap .gmsingle_term_label:empty { display:none; } .gmsingle_description_wrap .gmsingle_terms .gmsingle_term { display:inline-block; margin:0 12px 1px 0; } .gmsingle_description_wrap .gmsingle_terms .gmsingle_term a { white-space:nowrap; } .gmsingle_details_section { flex:1; width:33%; padding-right:7px; padding-left:7px; min-width:220px; max-width:100%; } .gmsingle_details_section .gmsingle_slide_details { margin:20px 0; } .gmsingle_location_section { flex:1; width:27%; padding-right:7px; padding-left:7px; min-width:220px; max-width:100%; } .gmsingle_location_section .gmsingle_location_info { margin:20px 0; } .gmsingle_location_section .gmsingle_location_info * { display:block; } .gmsingle_location_section .gmsingle_location_info img { width:100%; height:auto; } .gmsingle_badges { border-bottom:1px solid rgba(0, 0, 0, 0.1); padding-bottom:17px; margin-bottom:12px; text-align:left; font-weight:300; } .gmsingle_badges__column { display:inline-block; vertical-align:top; width:40%; min-width:80px; } .gmsingle_badges__column .gmsingle_badges__label { font-size:14px; } .gmsingle_badges__column .gmsingle_badges__count { font-size:20px; line-height:1em; margin-top:1px; } .gmsingle_exif { border-bottom:1px solid rgba(0, 0, 0, 0.1); padding-bottom:12px; margin-bottom:12px; text-align:left; font-size:14px; line-height:1.7em; font-weight:300; } .gmsingle_exif .gmsingle_camera_settings .gmsingle_separator { font-weight:200; padding:0 5px; display:inline-block; } .gmsingle_meta { padding-bottom:12px; margin-bottom:12px; text-align:left; font-size:14px; line-height:1.2em; font-weight:300; } .gmsingle_meta .gmsingle_meta_key { float:left; padding:3px 0; width:40%; min-width:80px; } .gmsingle_meta .gmsingle_meta_value { float:left; white-space:nowrap; padding:3px 0; text-transform:capitalize; } </style> <?php } else { echo apply_filters('the_gmedia_content', wpautop($gmedia->description)); } } elseif ('audio' == $gmedia->type && ($module = $gmCore->get_module_path('wavesurfer')) && $module['name'] === 'wavesurfer') { echo gmedia_shortcode(array('module' => 'wavesurfer', 'library' => $gmedia->ID, 'native' => true)); if (is_single()) { echo apply_filters('the_gmedia_content', wpautop($gmedia->description)); } } else { $ext1 = wp_get_audio_extensions(); $ext2 = wp_get_video_extensions(); $ext = array_merge($ext1, $ext2); if (in_array($gmedia->ext, $ext)) { $embed = do_shortcode("[embed]{$gmedia->url}[/embed]"); echo $embed; } else { $cover_url = $gmCore->gm_get_media_image($gmedia, 'web'); ?> <a class="gmedia-item-link" href="<?php echo $gmedia->url; ?> " download="true"><img class="gmedia-item" style="max-width:100%;" src="<?php echo $cover_url; ?> " alt="<?php esc_attr_e($gmedia->title); ?> "/></a> <?php } } $ob_content = ob_get_contents(); ob_end_clean(); if (is_single()) { $before = '<div class="GmediaGallery_SinglePage">'; $after = '</div>'; } else { $before = '<div class="GmediaGallery_ArchivePage">'; $after = '</div>'; } $output = $before . $ob_content . $after; } } else { if ('get_the_excerpt' != current_filter()) { if (!isset($post->term_id)) { $post->term_id = get_post_meta($post->ID, '_gmedia_term_ID', true); } if ($post->post_type == 'gmedia_gallery') { $output .= do_shortcode("[gmedia id={$post->term_id}]"); } else { $output .= do_shortcode("[gm id={$post->term_id}]"); } } } $output = str_replace(array("\r\n", "\r", "\n"), '', $output); $output = preg_replace('/ {2,}/', ' ', $output); $post->post_content = $output; $post->gmedia_content = $output; return $output; }
$gm_category_terms = $gmDB->get_terms('gmedia_category', array('fields' => 'names')); $gm_tag_terms = $gmDB->get_terms('gmedia_tag', array('fields' => 'names')); ?> <script type="text/javascript"> var gmedia_categories = <?php echo json_encode($gm_category_terms); ?> ; var gmedia_tags = <?php echo json_encode($gm_tag_terms); ?> ; </script> <?php foreach ($gmedia_query as &$item) { gmedia_item_more_data($item); $item->classes = array('gmedia-' . $item->type . '-item'); if ('publish' != $item->status) { if ('private' == $item->status) { $item->classes[] = 'list-group-item-info'; } elseif ('draft' == $item->status) { $item->classes[] = 'list-group-item-warning'; } } $item->selected = in_array($item->ID, (array) $gmProcessor->selected_items); if ($item->selected) { $item->classes[] = 'gm-selected'; } $item->in_stack = in_array($item->ID, (array) $gmProcessor->stack_items); if ((int) $item->author != $user_ID && !gm_user_can('edit_others_media')) { include dirname(__FILE__) . '/tpl/list-item.php';
/** * @title Image Editor */ function gmedia_image_editor() { global $gmCore, $gmDB; $gmid = $gmCore->_get('id'); $gmedia = $gmDB->get_gmedia($gmid); gmedia_item_more_data($gmedia); $is_modified = !empty($gmedia->meta['_modified'][0]); ?> <div class="panel panel-default" id="gmedit"> <div class="panel-heading clearfix"> <div class="btn-toolbar pull-right"> <?php if ($gmedia->path_original && $is_modified) { ?> <button type="button" id="gmedit-restore" name="gmedit_restore" class="btn btn-warning pull-left" data-confirm="<?php _e('Do you really want restore original image?'); ?> "><?php _e('Restore Original', 'grand-media'); ?> </button> <?php } ?> <div class="btn-group pull-left"> <button type="button" id="gmedit-reset" name="gmedit_reset" class="btn btn-default" data-confirm="<?php _e('Do you really want reset all changes?'); ?> "><?php _e('Reset', 'grand-media'); ?> </button> <button type="button" id="gmedit-save" name="gmedit_save" data-loading-text="<?php _e('Working', 'grand-media'); ?> " data-reset-text="<?php _e('Save image', 'grand-media'); ?> " class="btn btn-primary"><?php _e('Save image', 'grand-media'); ?> </button> </div> <?php wp_nonce_field('gmedit-save'); ?> </div> <div class="gmedit-tool-button gmedit-rotate left" title="<?php _e('Rotate Counterclockwise', 'grand-media'); ?> "></div> <div class="gmedit-tool-button gmedit-rotate right" title="<?php _e('Rotate Clockwise', 'grand-media'); ?> "></div> <div class="gmedit-tool-button gmedit-tool flip_hor" data-tool="flip_hor" data-value="0" title="<?php _e('Flip Horizontal', 'grand-media'); ?> "></div> <div class="gmedit-tool-button gmedit-tool flip_ver" data-tool="flip_ver" data-value="0" title="<?php _e('Flip Vertical', 'grand-media'); ?> "></div> <div class="gmedit-tool-button gmedit-tool greyscale" data-tool="greyscale" data-value="0" title="<?php _e('Greyscale', 'grand-media'); ?> "></div> <div class="gmedit-tool-button gmedit-tool invert" data-tool="invert" data-value="0" title="<?php _e('Invert', 'grand-media'); ?> "></div> </div> <div class="panel-body"> <div class="row"> <div class="col-xs-7 col-md-9"> <div id="gmedit-preview"> <div id="gmedit-canvas-cont"> <canvas id="gmedit-canvas"></canvas> </div> <div id="gmedit-busy"></div> </div> <div id="gmedit-overlay"><span style="height:100%; width:1px; overflow:hidden;"></span><span><?php _e('Processing image', 'grand-media'); ?> </span></div> </div> <div class="col-xs-5 col-md-3 media-edit-sidebar"> <div id="media-edit-form-container"> <div class="alert-box" style="display:none;"></div> <h2><?php _e('Filters', 'grand-media'); ?> </h2> <ul id="gmedit-instruments"> <li class="gmedit-filter"> <h3><?php _e('Brightness', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="brightness" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="brightness" data-direction="plus">+</a> <span class="gmedit-filter-value" id="brightnessValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="brightness_slider" data-tool="brightness"></div> </li> <li class="gmedit-filter"> <h3><?php _e('Contrast', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="contrast" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="contrast" data-direction="plus">+</a> <span class="gmedit-filter-value" id="contrastValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="contrast_slider" data-tool="contrast"></div> </li> <li class="gmedit-filter"> <h3><?php _e('Saturation', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="saturation" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="saturation" data-direction="plus">+</a> <span class="gmedit-filter-value" id="saturationValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="saturation_slider" data-tool="saturation"></div> </li> <li class="gmedit-filter"> <h3><?php _e('Vibrance', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="vibrance" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="vibrance" data-direction="plus">+</a> <span class="gmedit-filter-value" id="vibranceValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="vibrance_slider" data-tool="vibrance"></div> </li> <li class="gmedit-filter"> <h3><?php _e('Exposure', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="exposure" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="exposure" data-direction="plus">+</a> <span class="gmedit-filter-value" id="exposureValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="exposure_slider" data-tool="exposure"></div> </li> <li class="gmedit-filter"> <h3><?php _e('Hue', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="hue" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="hue" data-direction="plus">+</a> <span class="gmedit-filter-value" id="hueValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="hue_slider" data-tool="hue"></div> </li> <li class="gmedit-filter"> <h3><?php _e('Sepia', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="sepia" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="sepia" data-direction="plus">+</a> <span class="gmedit-filter-value" id="sepiaValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="sepia_slider" data-tool="sepia"></div> </li> <li class="gmedit-filter"> <h3><?php _e('Noise', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="noise" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="noise" data-direction="plus">+</a> <span class="gmedit-filter-value" id="noiseValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="noise_slider" data-tool="noise"></div> </li> <li class="gmedit-filter"> <h3><?php _e('Clip', 'grand-media'); ?> </h3> <div class="pull-right"> <a href="#" class="gmedit-filter-pm text-hide" data-tool="clip" data-direction="minus">-</a> <a href="#" class="gmedit-filter-pm text-hide" data-tool="clip" data-direction="plus">+</a> <span class="gmedit-filter-value" id="clipValue">0</span> </div> <div class="gmedit-filter-edit"></div> <div class="gmedit-slider-noui" id="clip_slider" data-tool="clip"></div> </li> </ul> </div> <div class="panel-footer form-inline"> <div class="form-group pull-right"> <label class="control-label"><?php _e('Apply to', 'grand-media'); ?> : </label> <select name="applyto" id="applyto" class="form-control input-sm"> <option value="web_thumb" selected="selected"><?php _e('Web-image, Thumbnail'); ?> </option> <option value="web"><?php _e('Only Web-image'); ?> </option> <option value="thumb"><?php _e('Only Thumbnail'); ?> </option> </select> </div> </div> </div> </div> </div> </div> <!--suppress JSUnresolvedVariable --> <script type="text/javascript"> jQuery(function($) { var sources = { web_thumb: '<?php echo $gmedia->url_web; ?> ', web: '<?php echo $gmedia->url_web; ?> ', thumb: '<?php echo $gmedia->url_thumb; ?> ', original: '<?php echo $gmedia->url_original; ?> ' }; var gmid = <?php echo $gmid; ?> ; var preinit_dom = '<canvas id="gmedit-canvas"></canvas>'; var editsrc = $("#applyto").val(); function div_frame() { $('.panel-body').css({top: $('.panel-heading').outerHeight()}); } div_frame(); $(window).on('resize', function() { div_frame(); }); var gmeditSave = function(a, b) { var btn = $('#gmedit-save'); btn.text(btn.data('loading-text')).prop('disabled', true); var post_data = { action: 'gmedit_save', id: gmid, image: a, applyto: $('#applyto').val(), _wpnonce: $('#_wpnonce').val() }; $.post(ajaxurl, post_data).always(function(c) { if(c.msg && !c.error) { var parent_doc = window.parent.document; $('#list-item-' + gmid, parent_doc) .find('.gmedia-thumb').attr('src', '<?php echo $gmedia->url_thumb; ?> ?' + (new Date).valueOf()) .end().find('.modified').text(c.modified); $('#gmedia-panel', parent_doc).before(c.msg); window.parent.closeModal('gmeditModal'); } else { btn.text(btn.data('reset-text')).prop('disabled', false); if(c.error) { $('#media-edit-form-container .alert-box').html(c.error).show(); } else { $('#media-edit-form-container .alert-box').text(c).show(); } } }); }; gmedit_init(sources[editsrc] + "?" + (new Date).valueOf(), "#gmedit", {save: gmeditSave}); $("body").on("change", "#applyto", function() { editsrc = $(this).val(); $('#gmedit-canvas-cont').html(preinit_dom); gmedit.resetFilters(); gmedit.init("#gmedit-canvas", sources[editsrc] + "?" + (new Date).valueOf()); }).on("click", "#gmedit-restore", function() { var btn = $('#gmedit-save'); btn.text(btn.data('loading-text')).prop('disabled', true); var post_data = { action: 'gmedit_restore', id: gmid, _wpnonce: $('#_wpnonce').val() }; $.post(ajaxurl, post_data).always(function(c) { if(c.msg && !c.error) { var parent_doc = window.parent.document; $('#list-item-' + gmid, parent_doc) .find('.gmedia-thumb').attr('src', '<?php echo $gmedia->url_thumb; ?> ?' + (new Date).valueOf()) .end().find('.modified').text(c.modified); $('#gmedia-panel', parent_doc).before(c.msg); $('#gmedit-canvas-cont').html(preinit_dom); gmedit.resetFilters(); gmedit.init("#gmedit-canvas", sources[editsrc] + "?" + (new Date).valueOf()); $('#media-edit-form-container .alert-box').html(c.msg).show(); $("#gmedit-restore").remove(); } else { if(c.error) { $('#media-edit-form-container .alert-box').html(c.error).show(); } else { $('#media-edit-form-container .alert-box').text(c).show(); } } btn.text(btn.data('reset-text')).prop('disabled', false); }); }); }); </script> <?php }