本文整理汇总了PHP中rtmedia_image函数的典型用法代码示例。如果您正苦于以下问题:PHP rtmedia_image函数的具体用法?PHP rtmedia_image怎么用?PHP rtmedia_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtmedia_image函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rtmedia_image_editor_content
/**
* Add the content for the image editor tab
*
* @global RTMediaQuery $rtmedia_query
*
* @param string $type
*/
function rtmedia_image_editor_content($type = 'photo')
{
global $rtmedia_query;
if (isset($rtmedia_query->media) && is_array($rtmedia_query->media) && isset($rtmedia_query->media[0]->media_type) && 'photo' === $rtmedia_query->media[0]->media_type && 'photo' === $type) {
$media_id = $rtmedia_query->media[0]->media_id;
$id = $rtmedia_query->media[0]->id;
$modify_button = $nonce = '';
if (current_user_can('edit_posts')) {
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
$nonce = wp_create_nonce("image_editor-{$media_id}");
$modify_button = '<p><input type="button" class="button rtmedia-image-edit" id="imgedit-open-btn-' . esc_attr($media_id) . '" onclick="imageEdit.open( \'' . esc_attr($media_id) . '\', \'' . esc_attr($nonce) . '\' )" value="' . esc_attr__('Modify Image', 'buddypress-media') . '"> <span class="spinner"></span></p>';
}
$image_path = rtmedia_image('rt_media_activity_image', $id, false);
echo '<div class="content" id="panel2">';
echo '<div class="rtmedia-image-editor-cotnainer" id="rtmedia-image-editor-cotnainer" >';
echo '<input type="hidden" id="rtmedia-filepath-old" name="rtmedia-filepath-old" value="' . esc_url($image_path) . '" />';
echo '<div class="rtmedia-image-editor" id="image-editor-' . esc_attr($media_id) . '"></div>';
$thumb_url = wp_get_attachment_image_src($media_id, 'thumbnail', true);
echo '<div id="imgedit-response-' . esc_attr($media_id) . '"></div>';
echo '<div class="wp_attachment_image" id="media-head-' . esc_attr($media_id) . '">' . '<p id="thumbnail-head-' . esc_attr($id) . '"><img class="thumbnail" src="' . esc_url(set_url_scheme($thumb_url[0])) . '" alt="" /></p>' . $modify_button . '</div>';
// @codingStandardsIgnoreLine
echo '</div>';
echo '</div>';
}
}
示例2: rtmedia_permalink
}
?>
<li class="rtmedia-list-item">
<a href ="<?php
rtmedia_permalink();
?>
" title="<?php
echo rtmedia_title();
?>
">
<div class="rtmedia-item-thumbnail">
<img src="<?php
rtmedia_image('rt_media_thumbnail');
?>
" alt="<?php
echo rtmedia_title();
?>
">
</div>
<?php
if (apply_filters('rtmedia_media_gallery_show_media_title', true)) {
?>
<div class="rtmedia-item-title">
<h4><?php
echo rtmedia_title();
?>
</h4>
示例3: json_output
function json_output()
{
global $rtmedia_query, $rtmedia;
$options = $rtmedia->options;
$media_array = array();
if ($rtmedia_query->media) {
foreach ($rtmedia_query->media as $key => $media) {
$media_array[$key] = $media;
$media_array[$key]->guid = rtmedia_image('rt_media_thumbnail', $media->id, false);
$media_array[$key]->rt_permalink = get_rtmedia_permalink($media->id);
$media_array[$key]->duration = rtmedia_duration($media->id);
$media_array[$key] = apply_filters('rtmedia_media_array_backbone', $media_array[$key]);
}
}
$return_array['data'] = $media_array;
$return_array['prev'] = rtmedia_page() - 1;
$return_array['next'] = rtmedia_offset() + rtmedia_per_page_media() < rtmedia_count() ? rtmedia_page() + 1 : -1;
if (isset($rtmedia->options['general_display_media']) && $options['general_display_media'] == 'pagination') {
$return_array['pagination'] = rtmedia_get_pagination_values();
}
echo json_encode($return_array);
die;
}
示例4: do_action
?>
">
<?php
do_action('rtmedia_before_item');
?>
<a href ="<?php
rtmedia_permalink();
?>
" title="<?php
echo rtmedia_title();
?>
">
<div class="rtmedia-item-thumbnail">
<img src="<?php
rtmedia_image("rt_media_thumbnail");
?>
" alt="<?php
rtmedia_image_alt();
?>
" >
</div>
<div class="rtmedia-item-title">
<h4 title="<?php
echo rtmedia_title();
?>
">
示例5: rtmedia_api_process_rtmedia_gallery_request
function rtmedia_api_process_rtmedia_gallery_request()
{
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
//Errors
$ec_media = 160002;
$msg_media = __('media list', 'rtmedia');
$ec_no_media = 160003;
$msg_no_media = __('no media found for requested media type', 'rtmedia');
$ec_invalid_media_type = 160004;
$msg_invalid_media_type = __('media_type not allowed', 'rtmedia');
global $rtmedia;
$rtmediamodel = new RTMediaModel();
//Media type to fetch
$media_type = $allowed_types = array_keys($rtmedia->allowed_types);
$media_type[] = 'album';
$allowed_types[] = 'album';
if (!empty($_REQUEST['media_type'])) {
if (!is_array($_REQUEST['media_type'])) {
$media_type = explode(',', $_REQUEST['media_type']);
} else {
$media_type = $_REQUEST['media_type'];
}
//Check array for currently allowed media types
$media_type = array_intersect($media_type, $allowed_types);
}
//Args for fetching media
$args = array('media_type' => $media_type);
//global
if (isset($_REQUEST['global'])) {
if ($_REQUEST['global'] == 'false') {
$args['context'] = array('compare' => 'IS NOT', 'value' => 'NULL');
}
}
//context
if (isset($_REQUEST['context'])) {
$args['context'] = $_REQUEST['context'];
}
//context Id
if (isset($_POST['context_id'])) {
$args['context_id'] = $_REQUEST['context_id'];
}
//Media Author
$media_author = '';
if (!is_super_admin()) {
$media_author = $this->user_id;
$args['media_author'] = $media_author;
}
if (!empty($_REQUEST['media_author'])) {
if (is_super_admin($this->user_id)) {
$media_author = (int) $_REQUEST['media_author'];
$args['media_author'] = $media_author;
}
}
$offset = !empty($_REQUEST['page']) ? (int) $_REQUEST['page'] : 0;
$per_page = isset($_REQUEST['per_page']) ? (int) $_REQUEST['per_page'] : 10;
$order_by = !empty($_REQUEST['order_by']) ? $_REQUEST['order_by'] : 'media_id desc';
$media_list = $rtmediamodel->get($args, $offset, $per_page, $order_by);
$media_result = array();
foreach ($media_list as $media) {
$data = array('id' => $media->id, 'media_title' => $media->media_title, 'album_id' => $media->album_id, 'media_type' => $media->media_type, 'media_author' => $media->media_author, 'url' => get_rtmedia_permalink($media->id), 'cover' => rtmedia_image('rt_media_thumbnail', $media->media_id, FALSE));
//for album list all medias
if ($media->media_type == 'album') {
$data['media'] = $this->rtmediajsonapifunction->rtmedia_api_album_media($media->id);
}
$media_result[] = $data;
}
if (!empty($media_result)) {
echo $this->rtmedia_api_response_object("TRUE", $ec_media, $msg_media, $media_result);
} else {
echo $this->rtmedia_api_response_object("FALSE", $ec_no_media, $msg_no_media);
}
}
示例6: rtmedia_album_image
/**
* Get album image
*
* @global object $rtmedia_media
* @global RTMediaQuery $rtmedia_query
* @global RTMedia $rtmedia
*
* @param string $size
* @param bool|int $id
*
* @return string
*/
function rtmedia_album_image($size = 'thumbnail', $id = false)
{
global $rtmedia_media, $rtmedia_query;
if (false === $id) {
$id = $rtmedia_media->id;
}
$model = new RTMediaModel();
if (isset($rtmedia_query->query['context_id']) && isset($rtmedia_query->query['context']) && 'group' !== $rtmedia_query->query['context']) {
if ('profile' === $rtmedia_query->query['context']) {
$media = $model->get_media(array('album_id' => $id, 'media_type' => 'photo', 'media_author' => $rtmedia_query->query['context_id'], 'context' => 'profile', 'context_id' => $rtmedia_query->query['context_id']), 0, 1);
} else {
$media = $model->get_media(array('album_id' => $id, 'media_type' => 'photo', 'media_author' => $rtmedia_query->query['context_id']), 0, 1);
}
} else {
if (isset($rtmedia_query->query['context_id']) && isset($rtmedia_query->query['context']) && 'group' === $rtmedia_query->query['context']) {
$media = $model->get_media(array('album_id' => $id, 'media_type' => 'photo', 'context_id' => $rtmedia_query->query['context_id']), 0, 1);
} else {
$media = $model->get_media(array('album_id' => $id, 'media_type' => 'photo'), 0, 1);
}
}
if ($media) {
$src = rtmedia_image($size, $media[0]->id, false);
} else {
global $rtmedia;
$src = $rtmedia->allowed_types['photo']['thumbnail'];
}
return $src;
}
示例7: template_redirect
function template_redirect($create_activity = true)
{
ob_start();
if (!count($_POST)) {
// @codingStandardsIgnoreLine
include get_404_template();
} else {
$nonce = $mode = '';
$_activity_id = -1;
if (isset($_REQUEST['rtmedia_upload_nonce'])) {
$nonce = sanitize_text_field(wp_unslash($_REQUEST['rtmedia_upload_nonce']));
}
if (isset($_REQUEST['mode'])) {
$mode = sanitize_text_field(wp_unslash($_REQUEST['mode']));
}
if (isset($_REQUEST['activity_id'])) {
$_activity_id = sanitize_text_field($_REQUEST['activity_id']);
}
$_redirect_url = filter_input(INPUT_POST, 'redirect', FILTER_SANITIZE_NUMBER_INT);
$rtupload = false;
$activity_id = -1;
$redirect_url = '';
if (wp_verify_nonce($nonce, 'rtmedia_upload_nonce')) {
$model = new RTMediaUploadModel();
do_action('rtmedia_upload_set_post_object');
$this->upload = $model->set_post_object();
if (-1 !== $_activity_id) {
$this->upload['activity_id'] = $_activity_id;
$activity_id = $_activity_id;
}
//if media upload is being made for a group, identify the group privacy and set media privacy accordingly
if (isset($this->upload['context']) && isset($this->upload['context_id']) && 'group' === $this->upload['context'] && function_exists('groups_get_group')) {
$group = groups_get_group(array('group_id' => $this->upload['context_id']));
if (isset($group->status) && 'public' !== $group->status) {
// if group is not public, then set media privacy as 20, so only the group members can see the images
$this->upload['privacy'] = '20';
} else {
// if group is public, then set media privacy as 0
$this->upload['privacy'] = '0';
}
}
$this->upload = apply_filters('rtmedia_media_param_before_upload', $this->upload);
$rtupload = new RTMediaUpload($this->upload);
$media_obj = new RTMediaMedia();
$media = $media_obj->model->get(array('id' => $rtupload->media_ids[0]));
$rtmedia_nav = new RTMediaNav();
$perma_link = '';
if (isset($media) && count($media) > 0) {
$perma_link = get_rtmedia_permalink($media[0]->id);
if ('photo' === $media[0]->media_type) {
$thumb_image = rtmedia_image('rt_media_thumbnail', $rtupload->media_ids[0], false);
} elseif ('music' === $media[0]->media_type) {
$thumb_image = $media[0]->cover_art;
} else {
$thumb_image = '';
}
if ('group' === $media[0]->context) {
$rtmedia_nav->refresh_counts($media[0]->context_id, array('context' => $media[0]->context, 'context_id' => $media[0]->context_id));
} else {
$rtmedia_nav->refresh_counts($media[0]->media_author, array('context' => 'profile', 'media_author' => $media[0]->media_author));
}
if (false !== $create_activity && class_exists('BuddyPress') && bp_is_active('activity')) {
$allow_single_activity = apply_filters('rtmedia_media_single_activity', false);
// Following will not apply to activity uploads. For first time activity won't be generated.
// Create activity first and pass activity id in response.
// todo fixme rtmedia_media_single_activity filter. It will create 2 activity with same media if uploaded from activity page.
$_rtmedia_update = filter_input(INPUT_POST, 'rtmedia_update', FILTER_SANITIZE_STRING);
if (-1 === intval($activity_id) && !(isset($_rtmedia_update) && 'true' === $_rtmedia_update) || $allow_single_activity) {
$activity_id = $media_obj->insert_activity($media[0]->media_id, $media[0]);
} else {
$media_obj->model->update(array('activity_id' => $activity_id), array('id' => $rtupload->media_ids[0]));
//
$same_medias = $media_obj->model->get(array('activity_id' => $activity_id));
$update_activity_media = array();
foreach ($same_medias as $a_media) {
$update_activity_media[] = $a_media->id;
}
$privacy = filter_input(INPUT_POST, 'privacy', FILTER_SANITIZE_NUMBER_INT);
if (empty($privacy)) {
$privacy = 0;
}
$obj_activity = new RTMediaActivity($update_activity_media, $privacy, false);
global $wpdb, $bp;
$user = get_userdata($same_medias[0]->media_author);
$username = '<a href="' . esc_url(get_rtmedia_user_link($same_medias[0]->media_author)) . '">' . esc_html($user->user_nicename) . '</a>';
$action = sprintf(esc_html__('%s added %d %s', 'buddypress-media'), $username, count($same_medias), RTMEDIA_MEDIA_SLUG);
$action = apply_filters('rtmedia_buddypress_action_text_fitler_multiple_media', $action, $username, count($same_medias), $user->user_nicename);
$wpdb->update($bp->activity->table_name, array('type' => 'rtmedia_update', 'content' => $obj_activity->create_activity_html(), 'action' => $action), array('id' => $activity_id));
}
// update group last active
if ('group' === $media[0]->context) {
RTMediaGroup::update_last_active($media[0]->context_id);
}
}
}
if (isset($this->upload['rtmedia_simple_file_upload']) && true == $this->upload['rtmedia_simple_file_upload']) {
if (isset($media) && count($media) > 0) {
if (isset($_redirect_url)) {
if (intval($_redirect_url) > 1) {
//bulkurl
//.........这里部分代码省略.........
示例8: template_redirect
/**
*
*/
function template_redirect($create_activity = true)
{
ob_start();
if (!count($_POST)) {
include get_404_template();
} else {
$nonce = $_REQUEST['rtmedia_upload_nonce'];
if (isset($_REQUEST['mode'])) {
$mode = $_REQUEST['mode'];
}
$rtupload = false;
$activity_id = -1;
$redirect_url = "";
if (wp_verify_nonce($nonce, 'rtmedia_upload_nonce')) {
$model = new RTMediaUploadModel();
do_action('rtmedia_upload_set_post_object');
$this->upload = $model->set_post_object();
if (isset($_POST['activity_id']) && $_POST['activity_id'] != -1) {
$this->upload['activity_id'] = $_POST['activity_id'];
$activity_id = $_POST['activity_id'];
}
// ////if media upload is being made for a group, identify the group privacy and set media privacy accordingly
if (isset($this->upload['context']) && isset($this->upload['context_id']) && $this->upload['context'] == 'group' && function_exists('groups_get_group')) {
$group = groups_get_group(array('group_id' => $this->upload['context_id']));
if (isset($group->status) && $group->status != 'public') {
// if group is not public, then set media privacy as 20, so only the group members can see the images
$this->upload['privacy'] = '20';
} else {
// if group is public, then set media privacy as 0
$this->upload['privacy'] = '0';
}
}
$this->upload = apply_filters('rtmedia_media_param_before_upload', $this->upload);
$rtupload = new RTMediaUpload($this->upload);
$mediaObj = new RTMediaMedia();
$media = $mediaObj->model->get(array('id' => $rtupload->media_ids[0]));
$rtMediaNav = new RTMediaNav();
$perma_link = "";
if (isset($media) && sizeof($media) > 0) {
$perma_link = get_rtmedia_permalink($media[0]->id);
if ($media[0]->media_type == "photo") {
$thumb_image = rtmedia_image("rt_media_thumbnail", $rtupload->media_ids[0], false);
} elseif ($media[0]->media_type == "music") {
$thumb_image = $media[0]->cover_art;
} else {
$thumb_image = "";
}
if ($media[0]->context == "group") {
$rtMediaNav->refresh_counts($media[0]->context_id, array("context" => $media[0]->context, 'context_id' => $media[0]->context_id));
} else {
$rtMediaNav->refresh_counts($media[0]->media_author, array("context" => "profile", 'media_author' => $media[0]->media_author));
}
if ($create_activity !== false && class_exists('BuddyPress')) {
$allow_single_activity = apply_filters('rtmedia_media_single_activity', false);
// Following will not apply to activity uploads. For first time activity won't be generated.
// Create activity first and pass activity id in response.
// todo fixme rtmedia_media_single_activity filter. It will create 2 activity with same media if uploaded from activity page.
if ($activity_id == -1 && !(isset($_POST["rtmedia_update"]) && $_POST["rtmedia_update"] == "true") || $allow_single_activity) {
$activity_id = $mediaObj->insert_activity($media[0]->media_id, $media[0]);
} else {
$mediaObj->model->update(array('activity_id' => $activity_id), array('id' => $rtupload->media_ids[0]));
//
$same_medias = $mediaObj->model->get(array('activity_id' => $activity_id));
$update_activity_media = array();
foreach ($same_medias as $a_media) {
$update_activity_media[] = $a_media->id;
}
$privacy = 0;
if (isset($_POST["privacy"])) {
$privacy = $_POST["privacy"];
}
$objActivity = new RTMediaActivity($update_activity_media, $privacy, false);
global $wpdb, $bp;
$user = get_userdata($same_medias[0]->media_author);
$username = '<a href="' . get_rtmedia_user_link($same_medias[0]->media_author) . '">' . $user->user_nicename . '</a>';
$action = sprintf(__('%s added %d %s', 'buddypress-media'), $username, sizeof($same_medias), RTMEDIA_MEDIA_SLUG);
$action = apply_filters('rtmedia_buddypress_action_text_fitler_multiple_media', $action, $username, sizeof($same_medias), $user->user_nicename);
$wpdb->update($bp->activity->table_name, array("type" => "rtmedia_update", "content" => $objActivity->create_activity_html(), 'action' => $action), array("id" => $activity_id));
}
// update group last active
if ($media[0]->context == "group") {
RTMediaGroup::update_last_active($media[0]->context_id);
}
}
}
if (isset($this->upload['rtmedia_simple_file_upload']) && $this->upload['rtmedia_simple_file_upload'] == true) {
if (isset($media) && sizeof($media) > 0) {
if (isset($_POST["redirect"])) {
if (intval($_POST["redirect"]) > 1) {
//bulkurl
if ($media[0]->context == "group") {
$redirect_url = trailingslashit(get_rtmedia_group_link($media[0]->context_id)) . RTMEDIA_MEDIA_SLUG;
} else {
$redirect_url = trailingslashit(get_rtmedia_user_link($media[0]->media_author)) . RTMEDIA_MEDIA_SLUG;
}
} else {
$redirect_url = get_rtmedia_permalink($media[0]->id);
//.........这里部分代码省略.........
示例9: rtmedia_api_album_media
function rtmedia_api_album_media($album_id)
{
if (empty($album_id)) {
return false;
}
$rtmediamodel = new RTMediaModel();
$args = array('album_id' => $album_id);
$media_list = $rtmediamodel->get($args);
$media_data = array();
if (!empty($media_list) && is_array($media_list)) {
foreach ($media_list as $media) {
$media_data[] = array('id' => $media->id, 'media_title' => $media->media_title, 'media_url' => get_rtmedia_permalink($media->media_id), 'media_author' => $media->media_author, 'cover' => rtmedia_image('rt_media_thumbnail', $media->media_id, FALSE));
}
}
return $media_data;
}
示例10: rtmedia_api_process_rtmedia_gallery_request
function rtmedia_api_process_rtmedia_gallery_request()
{
$this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
//Errors
$ec_media = 160002;
$msg_media = esc_html__('media list', 'buddypress-media');
$ec_no_media = 160003;
$msg_no_media = esc_html__('no media found for requested media type', 'buddypress-media');
$ec_invalid_media_type = 160004;
$msg_invalid_media_type = esc_html__('media_type not allowed', 'buddypress-media');
global $rtmedia;
$rtmediamodel = new RTMediaModel();
//Media type to fetch
$media_type = $allowed_types = array_keys($rtmedia->allowed_types);
$media_type[] = 'album';
$allowed_types[] = 'album';
$media_type_temp = filter_input(INPUT_POST, 'media_type', FILTER_SANITIZE_STRING);
$media_type_array = filter_input(INPUT_POST, 'media_type', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
if (!empty($media_type_temp) || !empty($media_type_array)) {
if (!is_array($media_type_array)) {
$media_type = explode(',', $media_type_array);
} else {
$media_type = $media_type_temp;
}
//Check array for currently allowed media types
$media_type = array_intersect($media_type, $allowed_types);
}
//Args for fetching media
$args = array('media_type' => $media_type);
//global
$global = filter_input(INPUT_POST, 'global', FILTER_SANITIZE_STRING);
if (isset($global)) {
if ('false' === $global) {
$args['context'] = array('compare' => 'IS NOT', 'value' => 'NULL');
}
}
//context
$context = filter_input(INPUT_POST, 'context', FILTER_SANITIZE_STRING);
if (isset($context)) {
$args['context'] = $context;
}
//context Id
$context_id = filter_input(INPUT_POST, 'context_id', FILTER_SANITIZE_NUMBER_INT);
if (isset($context_id)) {
$args['context_id'] = $context_id;
}
//album id
$album_id = filter_input(INPUT_POST, 'album_id', FILTER_SANITIZE_NUMBER_INT);
if (!empty($album_id)) {
$args['album_id'] = $album_id;
}
//Media Author
if (!is_super_admin()) {
$media_author = $this->user_id;
$args['media_author'] = $media_author;
}
$media_author = filter_input(INPUT_POST, 'media_author', FILTER_SANITIZE_NUMBER_INT);
if (!empty($media_author)) {
if (is_super_admin($this->user_id)) {
$args['media_author'] = (int) $media_author;
}
}
$page = filter_input(INPUT_POST, 'page', FILTER_SANITIZE_NUMBER_INT, FILTER_NULL_ON_FAILURE);
$per_page = filter_input(INPUT_POST, 'per_page', FILTER_SANITIZE_NUMBER_INT, FILTER_NULL_ON_FAILURE);
$order_by = filter_input(INPUT_POST, 'order_by', FILTER_SANITIZE_STRING, FILTER_NULL_ON_FAILURE);
$offset = !empty($page) ? (int) $page : 0;
$per_page = isset($per_page) && !is_null($per_page) ? (int) $per_page : 10;
$order_by = !empty($order_by) ? $order_by : 'media_id desc';
$media_list = $rtmediamodel->get($args, $offset, $per_page, $order_by);
$media_result = array();
foreach ($media_list as $media) {
$data = array('id' => $media->id, 'media_title' => $media->media_title, 'album_id' => $media->album_id, 'media_type' => $media->media_type, 'media_author' => $media->media_author, 'url' => esc_url(get_rtmedia_permalink($media->id)), 'cover' => rtmedia_image('rt_media_thumbnail', $media->media_id, false));
//for album list all medias
if ('album' === $media->media_type) {
$data['media'] = $this->rtmediajsonapifunction->rtmedia_api_album_media($media->id);
}
$media_result[] = $data;
}
if (!empty($media_result)) {
wp_send_json($this->rtmedia_api_response_object('TRUE', $ec_media, $msg_media, $media_result));
} else {
wp_send_json($this->rtmedia_api_response_object('FALSE', $ec_no_media, $msg_no_media));
}
}
示例11: rtmedia_edit_media_on_database
/**
* [rtmedia_edit_media_on_database]
* Update Media details on database while admin edit reported media
* @param [Array] $data Image Details
* @param [Number] $post_ID Media ID
* @return [array] $data
*/
function rtmedia_edit_media_on_database($data, $post_ID)
{
$post = get_post($post_ID);
if ($_REQUEST) {
if (isset($_REQUEST['postid']) && 'image-editor' == $_REQUEST['action'] && 'edit-attachment' == $_REQUEST['context']) {
$media = new RTMediaModel();
$media_available = $media->get_media(array('media_id' => $_REQUEST['postid']), 0, 1);
$media_id = $media_available[0]->id;
if (!empty($media_available)) {
$rtmedia_filepath_old = rtmedia_image('rt_media_activity_image', $media_id, false);
if (isset($rtmedia_filepath_old)) {
$is_valid_url = preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $rtmedia_filepath_old);
if ($is_valid_url && function_exists('bp_is_active') && bp_is_active('activity')) {
$thumbnailinfo = wp_get_attachment_image_src($post_ID, 'rt_media_activity_image');
$activity_id = rtmedia_activity_id($media_id);
if ($post_ID && !empty($activity_id)) {
global $wpdb, $bp;
if (!empty($bp->activity)) {
$media->model = new RTMediaModel();
$related_media_data = $media->model->get(array('activity_id' => $activity_id));
$related_media = array();
foreach ($related_media_data as $activity_media) {
$related_media[] = $activity_media->id;
}
$activity_text = bp_activity_get_meta($activity_id, 'bp_activity_text');
$activity = new RTMediaActivity($related_media, 0, $activity_text);
$activity_content_new = $activity->create_activity_html();
$activity_content = str_replace($rtmedia_filepath_old, wp_get_attachment_url($post_ID), $activity_content_new);
$wpdb->update($bp->activity->table_name, array('content' => $activity_content), array('id' => $activity_id));
}
}
}
}
}
}
}
return $data;
}
示例12: widget
/**
*
* Outputs the HTML code of this widget.
*
* @param array An array of standard parameters for widgets in this theme
* @param array An array of settings for this widget instance
* @return void
*
**/
function widget($args, $instance)
{
global $bp;
global $rtmedia_query, $rtmedia_interaction, $rtmedia_media;
global $rtmedia_backbone;
$cache = get_transient(md5($this->id));
$data_source_type = '';
// the part with the title and widget wrappers cannot be cached!
// in order to avoid problems with the calculating columns
//
extract($args, EXTR_SKIP);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Latest Photos', GKTPLNAME) : $instance['title'], $instance, $this->id_base);
echo $before_widget;
echo $before_title;
echo $title;
echo $after_title;
if ($cache) {
echo $cache;
echo $after_widget;
return;
}
ob_start();
//
$user_id = empty($instance['user_id']) ? '' : $instance['user_id'];
$offset = empty($instance['offset']) ? 0 : $instance['offset'];
$columns = empty($instance['columns']) ? 5 : $instance['columns'];
$rows = empty($instance['rows']) ? 2 : $instance['rows'];
$cache = empty($instance['cache']) ? 60 : $instance['cache'];
if (!is_numeric($offset)) {
$offset = 0;
} else {
$offset = intval($offset);
}
if (!is_numeric($rows)) {
$rows = 0;
} else {
$rows = intval($rows);
}
if (!is_numeric($columns)) {
$columns = 0;
} else {
$columns = intval($columns);
}
$model = new RTMediaModel();
if ($data_source_type == 'user') {
$media = $model->get_media(array('media_type' => 'photo', 'media_author' => $user_id), $offset, $columns * $rows);
} else {
$media = $model->get_media(array('media_type' => 'photo'), $offset, $columns * $rows);
}
if ($media == null) {
echo __('There has been no recent activity.', GKTPLNAME);
} else {
?>
<div class="gk-bp-latest-photos" data-cols="<?php
echo $columns;
?>
">
<div>
<?php
foreach ($media as $img) {
?>
<a href ="<?php
echo get_rtmedia_permalink(rtmedia_id($img->media_id));
?>
">
<img src="<?php
rtmedia_image("rt_media_thumbnail", rtmedia_id($img->media_id));
?>
" alt="<?php
_e('View full image', GKTPLNAME);
?>
" />
</a>
<?php
}
?>
</div>
</div>
<?php
}
// save the cache results
$cache_output = ob_get_flush();
if (is_numeric($cache) && $cache > 0) {
set_transient(md5($this->id), $cache_output, 60 * $cache);
} else {
delete_transient(md5($this->id));
}
//
echo $after_widget;
}
示例13: widget
/**
*
* Outputs the HTML code of this widget.
*
* @param array An array of standard parameters for widgets in this theme
* @param array An array of settings for this widget instance
* @return void
*
**/
function widget($args, $instance)
{
global $bp;
global $rtmedia_query, $rtmedia_interaction, $rtmedia_media;
global $rtmedia_backbone;
$cache = get_transient(md5($this->id));
// the part with the title and widget wrappers cannot be cached!
// in order to avoid problems with the calculating columns
//
extract($args, EXTR_SKIP);
$title = apply_filters('widget_title', empty($instance['title']) ? __('BuddyPress Activity', GKTPLNAME) : $instance['title'], $instance, $this->id_base);
echo $before_widget;
echo $before_title;
echo $title;
echo $after_title;
if ($cache) {
echo $cache;
echo $after_widget;
return;
}
ob_start();
//
$data_source_type = empty($instance['data_source_type']) ? 'latest' : $instance['data_source_type'];
$user_id = empty($instance['user_id']) ? '' : $instance['user_id'];
$total_amount = empty($instance['total_amount']) ? 8 : $instance['total_amount'];
$show_username = empty($instance['show_username']) ? 'enable' : $instance['show_username'];
$show_readmore = empty($instance['show_readmore']) ? 'enable' : $instance['show_readmore'];
$amount_page = empty($instance['amount_page']) ? 4 : $instance['amount_page'];
$autoanimation = empty($instance['autoanimation']) ? 'disable' : $instance['autoanimation'];
$photo_width = empty($instance['photo_width']) ? 310 : $instance['photo_width'];
$offset = empty($instance['offset']) ? 0 : $instance['offset'];
if (!is_numeric($offset)) {
$offset = 0;
} else {
$offset = intval($offset);
}
if (!is_numeric($total_amount)) {
$total_amount = 0;
} else {
$total_amount = intval($total_amount);
}
$width = 3000;
$new_width = $total_amount * $photo_width;
if ($new_width > 3000) {
$width = $new_width;
}
$model = new RTMediaModel();
if ($data_source_type == 'user') {
$media = $model->get_media(array('media_type' => 'photo', 'media_author' => $user_id), $offset, $total_amount);
} else {
$media = $model->get_media(array('media_type' => 'photo'), $offset, $total_amount);
}
?>
<div data-cols="<?php
echo $amount_page;
?>
" style="width: <?php
echo $width;
?>
px" <?php
if ($autoanimation == 'enabled') {
echo 'class="animate"';
}
?>
>
<?php
if ($media == null) {
?>
<h4> <?php
echo __('GK BuddyPress Gallery: There has been no recent activity.', GKTPLNAME);
?>
</h4>
<?php
} else {
?>
<?php
foreach ($media as $img) {
?>
<figure style="width: <?php
echo $photo_width;
?>
px">
<img src="<?php
rtmedia_image("rt_media_activity_image", rtmedia_id($img->media_id));
?>
" alt="<?php
_e('View full image', GKTPLNAME);
//.........这里部分代码省略.........
示例14: json_output
function json_output()
{
global $rtmedia_query;
$media_array = array();
if ($rtmedia_query->media) {
foreach ($rtmedia_query->media as $key => $media) {
$media_array[$key] = $media;
$media_array[$key]->guid = rtmedia_image('rt_media_thumbnail', $media->id, false);
$media_array[$key]->rt_permalink = get_rtmedia_permalink($media->id);
}
}
$return_array['data'] = $media_array;
$return_array['prev'] = rtmedia_page() - 1;
$return_array['next'] = rtmedia_offset() + rtmedia_per_page_media() < rtmedia_count() ? rtmedia_page() + 1 : -1;
echo json_encode($return_array);
die;
}