• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_image_send_to_editor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_image_send_to_editor函数的典型用法代码示例。如果您正苦于以下问题:PHP get_image_send_to_editor函数的具体用法?PHP get_image_send_to_editor怎么用?PHP get_image_send_to_editor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_image_send_to_editor函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: test_wp_ajax_send_attachment_to_editor_should_return_an_image

 /**
  * @ticket 36578
  */
 public function test_wp_ajax_send_attachment_to_editor_should_return_an_image()
 {
     // Become an administrator
     $post = $_POST;
     $user_id = self::factory()->user->create(array('role' => 'administrator', 'user_login' => 'user_36578_administrator', 'user_email' => '[email protected]'));
     wp_set_current_user($user_id);
     $_POST = array_merge($_POST, $post);
     $filename = DIR_TESTDATA . '/images/canola.jpg';
     $contents = file_get_contents($filename);
     $upload = wp_upload_bits(basename($filename), null, $contents);
     $attachment = $this->_make_attachment($upload);
     // Set up a default request
     $_POST['nonce'] = wp_create_nonce('media-send-to-editor');
     $_POST['html'] = 'Bar Baz';
     $_POST['post_id'] = 0;
     $_POST['attachment'] = array('id' => $attachment, 'align' => 'left', 'image-size' => 'large', 'image_alt' => 'Foo bar', 'url' => 'http://example.com/');
     // Make the request
     try {
         $this->_handleAjax('send-attachment-to-editor');
     } catch (WPAjaxDieContinueException $e) {
         unset($e);
     }
     // Get the response.
     $response = json_decode($this->_last_response, true);
     $expected = get_image_send_to_editor($attachment, '', '', 'left', 'http://example.com/', false, 'large', 'Foo bar');
     // Ensure everything is correct
     $this->assertTrue($response['success']);
     $this->assertEquals($expected, $response['data']);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:32,代码来源:Attachments.php


示例2: network_shared_media_media_upload

function network_shared_media_media_upload()
{
    global $blog_id, $post;
    if (isset($_POST['send'])) {
        $nsm_blog_id = (int) $_GET['blog_id'];
        reset($_POST['send']);
        $nsm_send_id = (int) key($_POST['send']);
    }
    /* copied from wp-admin/inculdes/ajax-actions.php wp_ajax_send_attachment_to_editor() */
    if (isset($nsm_blog_id) && isset($nsm_send_id)) {
        switch_to_blog($nsm_blog_id);
        if (!current_user_can('upload_files')) {
            $current_blog_name = get_bloginfo('name');
            restore_current_blog();
            wp_die(__('You do not have permission to upload files to site: ') . $current_blog_name);
        }
        $attachment = wp_unslash($_POST['attachments'][$nsm_send_id]);
        $id = $nsm_send_id;
        if (!($post = get_post($id))) {
            wp_send_json_error();
        }
        if ('attachment' != $post->post_type) {
            wp_send_json_error();
        }
        $rel = $url = '';
        $html = $title = isset($attachment['post_title']) ? $attachment['post_title'] : '';
        if (!empty($attachment['url'])) {
            $url = $attachment['url'];
            if (strpos($url, 'attachment_id') || get_attachment_link($id) == $url) {
                $rel = ' rel="attachment wp-att-' . $id . '"';
            }
            $html = '<a href="' . esc_url($url) . '"' . $rel . '>' . $html . '</a>';
        }
        if ('image' === substr($post->post_mime_type, 0, 5)) {
            $align = isset($attachment['align']) ? $attachment['align'] : 'none';
            $size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium';
            $alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : '';
            $caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : '';
            $title = '';
            // We no longer insert title tags into <img> tags, as they are redundant.
            $html = get_image_send_to_editor($id, $caption, $title, $align, $url, (bool) $rel, $size, $alt);
        } elseif ('video' === substr($post->post_mime_type, 0, 5) || 'audio' === substr($post->post_mime_type, 0, 5)) {
            global $wp_embed;
            $meta = get_post_meta($id, '_wp_attachment_metadata', true);
            $html = $wp_embed->shortcode($meta, $url);
        }
        /** This filter is documented in wp-admin/includes/media.php */
        $html = apply_filters('media_send_to_editor', $html, $id, $attachment);
        // replace wp-image-<id>, wp-att-<id> and attachment_<id>
        $html = preg_replace(array('#(caption id="attachment_)(\\d+")#', '#(wp-image-|wp-att-)(\\d+)#'), array(sprintf('${1}nsm_%s_${2}', esc_attr($nsm_blog_id)), sprintf('${1}nsm-%s-${2}', esc_attr($nsm_blog_id))), $html);
        if (isset($_POST['chromeless']) && $_POST['chromeless']) {
            // WP3.5+ media browser is identified by the 'chromeless' parameter
            exit($html);
        } else {
            return media_send_to_editor($html);
        }
    }
}
开发者ID:ryan2407,项目名称:Vision,代码行数:58,代码来源:network_shared_media.php


示例3: mfrh_media_send_to_editor

function mfrh_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post =& get_post($attachment_id);
    if (substr($post->post_mime_type, 0, 5) == 'image') {
        $url = wp_get_attachment_url($attachment_id);
        $align = !empty($attachment['align']) ? $attachment['align'] : 'none';
        $size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium';
        $alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : '';
        $rel = $url == get_attachment_link($attachment_id);
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
    }
    return $html;
}
开发者ID:rudeone,项目名称:dp,代码行数:13,代码来源:media-file-renamer.php


示例4: wp_ajax_send_attachment_to_editor

/**
 * Ajax handler for sending an attachment to the editor.
 *
 * Generates the HTML to send an attachment to the editor.
 * Backwards compatible with the media_send_to_editor filter
 * and the chain of filters that follow.
 *
 * @since 3.5.0
 */
function wp_ajax_send_attachment_to_editor()
{
    check_ajax_referer('media-send-to-editor', 'nonce');
    $attachment = wp_unslash($_POST['attachment']);
    $id = intval($attachment['id']);
    if (!($post = get_post($id))) {
        wp_send_json_error();
    }
    if ('attachment' != $post->post_type) {
        wp_send_json_error();
    }
    if (current_user_can('edit_post', $id)) {
        // If this attachment is unattached, attach it. Primarily a back compat thing.
        if (0 == $post->post_parent && ($insert_into_post_id = intval($_POST['post_id']))) {
            wp_update_post(array('ID' => $id, 'post_parent' => $insert_into_post_id));
        }
    }
    $rel = '';
    $url = empty($attachment['url']) ? '' : $attachment['url'];
    if (strpos($url, 'attachment_id') || get_attachment_link($id) == $url) {
        $rel = ' rel="attachment wp-att-' . $id . '"';
    }
    remove_filter('media_send_to_editor', 'image_media_send_to_editor');
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        $align = isset($attachment['align']) ? $attachment['align'] : 'none';
        $size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium';
        $alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : '';
        // No whitespace-only captions.
        $caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : '';
        if ('' === trim($caption)) {
            $caption = '';
        }
        $title = '';
        // We no longer insert title tags into <img> tags, as they are redundant.
        $html = get_image_send_to_editor($id, $caption, $title, $align, $url, $rel, $size, $alt);
    } elseif (wp_attachment_is('video', $post) || wp_attachment_is('audio', $post)) {
        $html = stripslashes_deep($_POST['html']);
    } else {
        $html = isset($attachment['post_title']) ? $attachment['post_title'] : '';
        if (!empty($url)) {
            $html = '<a href="' . esc_url($url) . '"' . $rel . '>' . $html . '</a>';
        }
    }
    /** This filter is documented in wp-admin/includes/media.php */
    $html = apply_filters('media_send_to_editor', $html, $id, $attachment);
    wp_send_json_success($html);
}
开发者ID:hughnet,项目名称:WordPress,代码行数:56,代码来源:ajax-actions.php


示例5: image_media_send_to_editor

/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $html
 * @param unknown_type $attachment_id
 * @param unknown_type $attachment
 * @return unknown
 */
function image_media_send_to_editor($html, $attachment_id, $attachment)
{
    $post =& get_post($attachment_id);
    if (substr($post->post_mime_type, 0, 5) == 'image') {
        $url = $attachment['url'];
        if (isset($attachment['align'])) {
            $align = $attachment['align'];
        } else {
            $align = 'none';
        }
        if (!empty($attachment['image-size'])) {
            $size = $attachment['image-size'];
        } else {
            $size = 'medium';
        }
        $rel = $url == get_attachment_link($attachment_id);
        return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size);
    }
    return $html;
}
开发者ID:Alenjandro,项目名称:data-my-share,代码行数:30,代码来源:media.php


示例6: handle_sideload

	function handle_sideload($post) {

		if ( empty( $post['format'] ) )
			return; // Nothing to import.

		switch ( $post['format'] ) {
		case 'gallery':
			if ( !empty( $post['gallery'] ) ) {
				foreach ( $post['gallery'] as $i => $photo ) {
					$id = $this->handle_sideload_import( $post, (string)$photo['src'], (string)$photo['caption']);
					if ( is_wp_error($id) )
						return $id;
				}
				$post['post_content'] = "[gallery]\n" . $post['post_content'];
				$post = apply_filters( 'tumblr_importer_format_post', $post );
				do_action( 'tumblr_importer_metadata', $post );
				wp_update_post($post);
				break; // If we processed a gallery, break, otherwise let it fall through to the Image handler
			}

		case 'image':
			if ( isset( $post['media']['src'] ) ) {
				$id = $this->handle_sideload_import( $post, (string)$post['media']['src'], (string)$post['post_title']);
				if ( is_wp_error($id) )
					return $id;

				$link = !empty($post['media']['link']) ? $post['media']['link'] : null;
				// image_send_to_editor has a filter to wrap in a shortcode.
				$post_content = $post['post_content'];
				$post['post_content'] = get_image_send_to_editor($id, (string)$post['post_title'], (string)$post['post_title'], 'none', $link, true, 'full' );
				$post['post_content'] .= $post_content;
				$post['meta']['attribution'] = $link;
				$post = apply_filters( 'tumblr_importer_format_post', $post );
				do_action( 'tumblr_importer_metadata', $post );
				//$post['post_content'] .= "\n" . $post['post_content']; // the [caption] shortcode doesn't allow HTML, but this might have some extra markup
				wp_update_post($post);
			}
			
			break;
		
		case 'audio':
			// Handle Tumblr Hosted Audio
			if ( isset( $post['media']['audio'] ) ) {
				$id = $this->handle_sideload_import( $post, (string)$post['media']['audio'], $post['post_title'], (string)$post['media']['filename'] );
				if ( is_wp_error($id) )
					return $id;
				$post['post_content'] = wp_get_attachment_link($id) . "\n" . $post['post_content'];
			} else {
				// Try to work out a "source" link to display Tumblr-style.
				preg_match( '/(http[^ "<>\']+)/', $post['post_content'], $matches );
				if ( isset( $matches[1] ) ) {
					$url_parts = parse_url( $matches[1] );
					$post['meta']['attribution'] = $url_parts['scheme'] . "://" . $url_parts['host'] . "/";
				}
			}
			$post = apply_filters( 'tumblr_importer_format_post', $post );
			do_action( 'tumblr_importer_metadata', $post );
			wp_update_post($post);
			break;
			
		case 'video':
			// Handle Tumblr hosted video
			if ( isset( $post['media']['video'] ) ) {
				$id = $this->handle_sideload_import( $post, (string)$post['media']['video'], $post['post_title'], (string)$post['media']['filename'] );
				if ( is_wp_error($id) )
					return $id;

				// @TODO: Check/change this to embed the imported video.				
				$link = wp_get_attachment_link($id) . "\n" . $post['post_content'];
				$post['post_content'] = $link;
				$post['meta']['attribution'] = $link;
			} else {
				// Try to work out a "source" link to mimic Tumblr's post formatting.
				preg_match( '/(http[^ "<>\']+)/', $post['post_content'], $matches );
				if ( isset( $matches[1] ) ) {
					$url_parts = parse_url( $matches[1] );
					$post['meta']['attribution'] = $url_parts['scheme'] . "://" . $url_parts['host'] . "/";
				}
			}
			$post = apply_filters( 'tumblr_importer_format_post', $post );
			do_action( 'tumblr_importer_metadata', $post );
			wp_update_post($post);

			// Else, Check to see if the url embedded is handled by oEmbed (or not)
			break;
		}

		return true; // all processed
	}
开发者ID:unisexx,项目名称:drtooth,代码行数:89,代码来源:tumblr-importer.php


示例7: test_get_image_send_to_editor_defaults_no_caption_no_rel

 /**
  * @ticket 36084
  */
 function test_get_image_send_to_editor_defaults_no_caption_no_rel()
 {
     $id = self::$large_id;
     $caption = '';
     $title = 'A test title value.';
     $align = 'left';
     $url = get_permalink($id);
     $rel = '';
     $size = 'thumbnail';
     $alt = 'An example alt value.';
     // Calculate attachment data.
     $attachment = wp_get_attachment_image_src($id, $size);
     $html = '<a href="%1$s"><img src="%2$s" alt="%3$s" width="%4$d" height="%5$d" class="align%6$s size-%7$s wp-image-%8$d" /></a>';
     $expected = sprintf($html, $url, $attachment[0], $alt, $attachment[1], $attachment[2], $align, $size, $id);
     $this->assertSame($expected, get_image_send_to_editor($id, $caption, $title, $align, $url, $rel, $size, $alt));
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:19,代码来源:media.php


示例8: wp_ajax_send_attachment_to_editor

/**
 * Generates the HTML to send an attachment to the editor.
 * Backwards compatible with the media_send_to_editor filter and the chain
 * of filters that follow.
 *
 * @since 3.5.0
 */
function wp_ajax_send_attachment_to_editor()
{
    check_ajax_referer('media-send-to-editor', 'nonce');
    $attachment = stripslashes_deep($_POST['attachment']);
    $id = intval($attachment['id']);
    if (!($post = get_post($id))) {
        wp_send_json_error();
    }
    if (!current_user_can('edit_post', $id)) {
        wp_send_json_error();
    }
    if ('attachment' != $post->post_type) {
        wp_send_json_error();
    }
    // If this attachment is unattached, attach it. Primarily a back compat thing.
    if (0 == $post->post_parent && ($insert_into_post_id = intval($_POST['post_id']))) {
        wp_update_post(array('ID' => $id, 'post_parent' => $insert_into_post_id));
    }
    $rel = $url = '';
    $html = $title = isset($attachment['post_title']) ? $attachment['post_title'] : '';
    if (!empty($attachment['url'])) {
        $url = $attachment['url'];
        if (strpos($url, 'attachment_id') || get_attachment_link($id) == $url) {
            $rel = ' rel="attachment wp-att-' . $id . '"';
        }
        $html = '<a href="' . esc_url($url) . '"' . $rel . '>' . $html . '</a>';
    }
    remove_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        $align = isset($attachment['align']) ? $attachment['align'] : 'none';
        $size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium';
        $alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : '';
        $caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : '';
        $title = '';
        // We no longer insert title tags into <img> tags, as they are redundant.
        $html = get_image_send_to_editor($id, $caption, $title, $align, $url, (bool) $rel, $size, $alt);
    }
    $html = apply_filters('media_send_to_editor', $html, $id, $attachment);
    wp_send_json_success($html);
}
开发者ID:neopunisher,项目名称:WordPress,代码行数:47,代码来源:ajax-actions.php


示例9: dwtp_attach_images

function dwtp_attach_images($post_array)
{
    global $image_settings;
    $post_id = $post_array['ID'];
    $post_content = $post_array['post_content'];
    if (empty($post_id)) {
        gdocs_log("Post ID was null when trying to insert images", "error");
        return false;
    }
    $attached_guids = array();
    if (!empty($post_id) && ($images = get_posts(array('post_parent' => $post_id, 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC')))) {
        foreach ($images as $image) {
            $attached_images[] = get_image_send_to_editor($image->ID, '', $image->post_title, $image_settings['image_alignment'], wp_get_attachment_url($image->ID), FALSE, $image_settings['image_size'], $image->post_content);
            if (preg_match('/gdocs.{10}_/', $image->guid, $guid_match) > 0) {
                //match guids with the gdocs id inserted
                $attached_guids[] = $guid_match[0];
                //for identifying gdocs images added since before
            } else {
                $attached_guids[] = $image->guid;
            }
        }
    }
    //MF
    preg_match_all('/<img(.*?)>/', $post_content, $doc_imgs, PREG_OFFSET_CAPTURE);
    gdocs_log("Image GUIDs: " . implode($attached_guids), "debug");
    $upload_dir = wp_upload_dir();
    $path = $upload_dir['path'] . '/' . $image_settings['gdocs_image_folder'];
    //assumed subdir of upload
    if (!file_exists($path)) {
        mkdir($path);
    }
    $replace_offset = 0;
    foreach ($doc_imgs[0] as $doc_img) {
        //$doc_imgs[0] because we only need first pattern, not the subpattern
        preg_match('/src="https(.*?)"/', $doc_img[0], $src_match);
        //Use doc_img[0] as we also match position in index [1]
        $img_hash = 'gdocs' . substr($src_match[1], -10) . '_';
        // Pick file name hash from last 10 of gdocs user content hash (hope it's static!)
        $new_img_tag = '';
        $existing_img = array_search($img_hash, $attached_guids);
        // see if we already have this img as attachment
        if ($existing_img === FALSE) {
            // Gdocs defaults to HTTPSing their images, but we can go with normal http for simplicity
            $headers = wp_get_http('http' . $src_match[1], $path . $img_hash);
            $contentdisposition = explode('"', $headers["content-disposition"]);
            //pattern is: inline;filename="xxx.jpg"
            if (count($contentdisposition) > 1) {
                $filename = urldecode($contentdisposition[1]);
                // filename may include URL characters that mess up later
                $file_ext = strripos($filename, '.');
                // look for extension from end of string
                $name = $file_ext > 0 ? substr($filename, 0, $file_ext) : $filename;
                //strip out file type from name
            } else {
                $filename = 'unknown.jpg';
                $name = "unknown";
            }
            $filename = $img_hash . $filename;
            // for uniqueness combine with hash
            $newpath = $path . $filename;
            rename($path . $img_hash, $newpath);
            $wp_filetype = wp_check_filetype(basename($newpath), null);
            $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $name, 'post_name' => $name, 'guid' => $upload_dir['baseurl'] . '/gdocs/' . $filename, 'post_content' => '', 'post_status' => 'inherit');
            $attach_id = wp_insert_attachment($attachment, $newpath, $post_id);
            $attach_data = wp_generate_attachment_metadata($attach_id, $newpath);
            wp_update_attachment_metadata($attach_id, $attach_data);
            gdocs_log("Inserted attachment " . implode($attachment) . " to post {$post_id} and generated metadata:", "debug");
            $new_img_tag = get_image_send_to_editor($attach_id, '', $name, $image_settings['image_alignment'], wp_get_attachment_url($image->ID), FALSE, $image_settings['image_size'], '');
            gdocs_log("Downloaded https" . $src_match[1] . " as {$filename} (content-disp: " . $headers["content-disposition"] . ", hash {$img_hash} not found, index {$existing_img})\n", "debug");
        } else {
            $new_img_tag = $attached_images[$existing_img];
            gdocs_log("{$img_hash} already downloaded (index in guid: {$existing_img})\n", "debug");
        }
        // as we replace in post_content the originally matched positions will be offsetted, so we compensate
        $post_content = substr_replace($post_content, $new_img_tag, $doc_img[1] + $replace_offset, strlen($doc_img[0]));
        $replace_offset = $replace_offset + (strlen($new_img_tag) - strlen($doc_img[0]));
    }
    $post_array['post_content'] = $post_content;
    return $post_array;
}
开发者ID:ripperdoc,项目名称:Docs-to-WordPress,代码行数:80,代码来源:extend-clean.php


示例10: testGetPost

 public function testGetPost()
 {
     //add media item to test unattached images in content
     $upload = $this->_upload_file(dirname(dirname(__DIR__)) . '/data/250x250.png');
     $att_id = $this->_make_attachment($upload);
     $imgHtml = get_image_send_to_editor($att_id, 'Test Caption', 'Test Title', 'left');
     $content = "Proin nec risus a metus mattis eleifend. Quisque ullamcorper porttitor aliquam. " . "Donec ut vulputate diam. Etiam eu dui pretium, condimentum nisi eu, tincidunt elit. \n\n" . $imgHtml . " \n\n Morbi ipsum dolor, tristique quis lorem sit amet, blandit ornare arcu. " . "Phasellus facilisis varius porttitor. Nam gravida neque eros, id pellentesque nibh aliquam a.";
     //get_image_send_to_editor
     $test_data = $this->_insert_post(array('post_content' => $content), array('100x200.png', '100x300.png'));
     $upload = $this->_upload_file(dirname(dirname(__DIR__)) . '/data/100x500.png');
     $att_id = $this->_make_attachment($upload);
     set_post_thumbnail($test_data['post_id'], $att_id);
     list($status, $headers, $body) = $this->_getResponse(array('REQUEST_METHOD' => 'GET', 'PATH_INFO' => Voce\Thermal\get_api_base() . 'v1/posts/' . $test_data['post_id'], 'QUERY_STRING' => ''));
     $data = json_decode($body);
     $this->assertEquals('200', $status);
     $this->assertInternalType('object', $data);
     $post = get_post($test_data['post_id']);
     $checks = array('id' => array('type' => 'int', 'value' => $post->ID), 'id_str' => array('type' => 'string', 'value' => $post->ID), 'type' => array('type' => 'string', 'value' => 'post'), 'permalink' => array('type' => 'string', 'value' => get_permalink($post->ID)), 'parent' => array('type' => 'int', 'value' => $post->post_parent), 'parent_str' => array('type' => 'string', 'value' => $post->post_parent), 'date' => array('type' => 'string', 'value' => get_post_time('c', true, $post)), 'modified' => array('type' => 'string', 'value' => get_post_modified_time('c', true, $post)), 'status' => array('type' => 'string', 'value' => $post->post_status), 'comment_status' => array('type' => 'string', 'value' => $post->comment_status), 'comment_count' => array('type' => 'int', 'value' => 0), 'menu_order' => array('type' => 'int', 'value' => 0), 'title' => array('type' => 'string', 'value' => $post->post_title), 'name' => array('type' => 'string', 'value' => $post->post_name), 'excerpt' => array('type' => 'string'), 'excerpt_display' => array('type' => 'string'), 'content' => array('type' => 'string'), 'content_display' => array('type' => 'string'), 'author' => array('type' => 'object'), 'mime_type' => array('type' => 'string', 'value' => ''), 'meta' => array('type' => 'object'), 'taxonomies' => array('type' => 'object'), 'media' => array('type' => 'array'));
     foreach ($checks as $attrib => $check) {
         $this->assertObjectHasAttribute($attrib, $data);
         $this->assertInternalType($check['type'], $data->{$attrib});
         if (isset($check['value'])) {
             $this->assertEquals($check['value'], $data->{$attrib});
         }
     }
     $this->assertEquals(4, count($data->media));
 }
开发者ID:katymdc,项目名称:thermal-api,代码行数:27,代码来源:test-Posts.php


示例11: isset

 $html = $title = isset($attachment['post_title']) ? $attachment['post_title'] : '';
 if (!empty($attachment['url'])) {
     $url = $attachment['url'];
     if (strpos($url, 'attachment_id') || get_attachment_link($id) == $url) {
         $rel = ' rel="attachment wp-att-' . $id . '"';
     }
     $html = '<a href="' . esc_url($url) . '"' . $rel . '>' . $html . '</a>';
 }
 if ('image' === substr($post->post_mime_type, 0, 5)) {
     $align = isset($attachment['align']) ? $attachment['align'] : 'none';
     $size = isset($attachment['image-size']) ? $attachment['image-size'] : 'medium';
     $alt = isset($attachment['image_alt']) ? $attachment['image_alt'] : '';
     $caption = isset($attachment['post_excerpt']) ? $attachment['post_excerpt'] : '';
     $title = '';
     // We no longer insert title tags into <img> tags, as they are redundant.
     $html = get_image_send_to_editor($id, $caption, $title, $align, $url, (bool) $rel, $size, $alt);
 } elseif ('video' === substr($post->post_mime_type, 0, 5) || 'audio' === substr($post->post_mime_type, 0, 5)) {
     global $wp_embed;
     $meta = get_post_meta($id, '_wp_attachment_metadata', true);
     $html = $wp_embed->shortcode($meta, $url);
 }
 /** This filter is documented in wp-admin/includes/media.php */
 $html = apply_filters('media_send_to_editor', $html, $id, $attachment);
 // replace wp-image-<id>, wp-att-<id> and attachment_<id>
 $html = preg_replace(array('#(caption id="attachment_)(\\d+")#', '#(wp-image-|wp-att-)(\\d+)#'), array(sprintf('${1}nsm_%s_${2}', esc_attr($nsm_blog_id)), sprintf('${1}nsm-%s-${2}', esc_attr($nsm_blog_id))), $html);
 if (isset($_POST['chromeless']) && $_POST['chromeless']) {
     // WP3.5+ media browser is identified by the 'chromeless' parameter
     exit($html);
 } else {
     return media_send_to_editor($html);
 }
开发者ID:Buooy,项目名称:wp_network_shared_media,代码行数:31,代码来源:media-upload.php



注:本文中的get_image_send_to_editor函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_image_tag函数代码示例发布时间:2022-05-15
下一篇:
PHP get_image_path函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap