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

PHP get_attached_media函数代码示例

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

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



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

示例1: task

 /**
  * Run the attachment deletion task.
  *
  * Uses transients to ensure that only small batches of posts are done each time.
  * Once a batch is complete, the post offset transient is iterated.
  */
 public function task()
 {
     // Set initial offset
     if (false == ($offset = get_transient('media_manager_offset'))) {
         set_transient('media_manager_offset', $offset = 0, DAY_IN_SECONDS);
     }
     $time = time();
     while (time() < $time + self::TIME_LIMIT) {
         // Get the post IDs
         $query = new WP_Query(array('post_type' => $this->get_post_types(), 'posts_per_page' => 1, 'post_status' => 'publish', 'offset' => $offset, 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'fields' => 'ids'));
         $post_ids = $query->posts;
         // Completed all posts, so delete offset and bail out
         if (empty($post_ids)) {
             delete_transient('media_manager_offset');
             return;
         }
         // Loop through the posts
         foreach ($post_ids as $key => $post_id) {
             $attached_media = get_attached_media('image', $post_id);
             $featured_id = get_post_thumbnail_id($post_id);
             // Loop through media attached to each post
             foreach ($attached_media as $x => $attachment) {
                 $attachment_id = $attachment->ID;
                 // If not a featured image, then delete the attachment
                 if ($attachment_id != $featured_id) {
                     wp_delete_post($attachment_id);
                 }
             }
             set_transient('media_manager_offset', $offset++, DAY_IN_SECONDS);
         }
         usleep(0.1 * 1000000);
         // Delaying the execution (reduces resource consumption)
     }
     return;
 }
开发者ID:forsitemedia,项目名称:media-manager,代码行数:41,代码来源:class-media-manager-delete.php


示例2: vskb_columns

function vskb_columns($vskb_cats, $columns, $subcats = false, $excludes = null, $includes = null)
{
    $return = "";
    $columnNames = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
    $return .= '<div id="vskb-' . $columnNames[$columns] . '">' . '<ul class="x-vskb-cat-list">';
    $content = '';
    // Get list of ICONs or images attached to the KB page, these can be icons.
    $media = get_attached_media('image');
    $icons = [];
    foreach ($media as $key => $val) {
        $icons[$val->post_name] = $val->guid;
    }
    $js = '';
    $count = 0;
    foreach ($vskb_cats as $cat) {
        if (!empty($excludes) && in_array($cat->slug, $excludes)) {
            continue;
        } else {
            if (!empty($includes) && !in_array($cat->slug, $includes)) {
                continue;
            }
        }
        // For each category we keep map in JS
        $js .= 'cats["' . $cat->slug . '"] = ' . $count . ';';
        $img = '';
        if (!empty($icons[$cat->slug . '-ico'])) {
            $img = '<img class="category-icon" src="' . $icons[$cat->slug . '-ico'] . '">';
        }
        // $return .= '<ul class="vskb-cat-list"><li class="vskb-cat-name"><a href="'. get_category_link( $cat->cat_ID ) .'" title="'. $cat->name .'" >'. $cat->name .'</a></li>';
        $return .= '<li class="x-vskb-cat-name"><a href="#' . $cat->slug . '" title="' . $cat->name . '" >' . $img . $cat->name . '</a></li>';
        $catColumn = $subCats ? 'category__in' : 'cat';
        $vskb_args = array('orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1, $catColumn => $cat->cat_ID);
        $vskb_posts = get_posts($vskb_args);
        $content .= '<div id="' . $cat->slug . '"><ul class="vskb-cat-list">';
        foreach ($vskb_posts as $single_post) {
            $content .= '<li class="vskb-post-name">';
            $content .= '<a href="' . get_permalink($single_post->ID) . '" rel="bookmark" title="' . get_the_title($single_post->ID) . '">' . get_the_title($single_post->ID) . '</a>';
            $content .= '</li>';
        }
        $content .= '</ul></div>';
        $count++;
    }
    $return .= '</ul>' . $content;
    $return .= '</div>';
    // Add jQuery
    $return .= '<script>
	jQuery( function() {
		var cats = {};
		' . $js . '
		console.log( window.location.hash, cats );
		whichTab = 0;
		jQuery( "#vskb-' . $columnNames[$columns] . '" ).tabs( { active : whichTab }).addClass( "ui-tabs-vertical ui-helper-clearfix" );
		jQuery( "#vskb-' . $columnNames[$columns] . ' li.x-vskb-cat-name" ).removeClass( "ui-corner-top" ).addClass( "ui-corner-left" );
	});
	</script>';
    return $return;
}
开发者ID:redline13,项目名称:wp-plugin-vertical-kb,代码行数:57,代码来源:vskb.php


示例3: get_post_field_images

 /**
  * Given information provided in an entry, get array of media IDs
  *
  * This is necessary because GF doesn't expect to need to update post images, only to create them.
  *
  * @see GFFormsModel::create_post()
  *
  * @since 1.17
  *
  * @param array $form Gravity Forms form array
  * @param array $entry Gravity Forms entry array
  *
  * @return array Array of "Field ID" => "Media IDs"
  */
 public static function get_post_field_images($form, $entry)
 {
     $post_data = self::get_post_fields($form, $entry);
     $media = get_attached_media('image', $entry['post_id']);
     $post_images = array();
     foreach ($media as $media_item) {
         foreach ((array) $post_data['images'] as $post_data_item) {
             if (rgar($post_data_item, 'title') === $media_item->post_title && rgar($post_data_item, 'description') === $media_item->post_content && rgar($post_data_item, 'caption') === $media_item->post_excerpt) {
                 $post_images["{$post_data_item['field_id']}"] = $media_item->ID;
             }
         }
     }
     return $post_images;
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:28,代码来源:class-gravityview-gfformsmodel.php


示例4: get_items

 public function get_items($request)
 {
     $id = $request['id'];
     $type = $request['type'];
     $query_result = get_attached_media($type, $id);
     $medias = array();
     foreach ($query_result as $media) {
         //$mediaItem = json_decode(get_data(rest_url('wp/v2/media/' . $media->ID)));
         $data = $this->prepare_item_for_response($media, $request);
         $medias[] = $this->prepare_response_for_collection($data);
         //$medias[] = $data;
     }
     $response = rest_ensure_response($medias);
     return $response;
 }
开发者ID:Afrozaar,项目名称:wp-api-v2-afrozaar-extras,代码行数:15,代码来源:class-wp-rest-media-extras-controller.php


示例5: delete_slider

function delete_slider()
{
    global $wpdb;
    // this is how you get access to the database
    $postId = intval(substr($_POST['slide-id'], 6));
    //first, delete all images attached to the post
    $attaches = get_attached_media('image', $postId);
    foreach ($attaches as $image) {
        wp_delete_attachment($image->ID, true);
    }
    //second,delete the post itself
    $deleted = wp_delete_post($postId, true);
    if ($deleted != false) {
        echo '1';
    } else {
        echo '-1';
    }
    wp_die();
    // this is required to terminate immediately and return a proper response
}
开发者ID:dev-wl,项目名称:torani,代码行数:20,代码来源:micro-css-slider.php


示例6: post_helper_basic

 /**
  * @test
  */
 public function post_helper_basic()
 {
     $num_categories = 3;
     $categories = $this->factory->category->create_many($num_categories);
     array_shift($categories);
     $args = array('post_name' => 'slug', 'post_author' => '1', 'post_date' => '2012-11-15 20:00:00', 'post_type' => 'post', 'post_status' => 'publish', 'post_title' => 'title', 'post_content' => 'content', 'post_category' => $categories, 'post_tags' => array('tag1', 'tag2'));
     $helper = new Helper($args);
     $post_id = $helper->insert();
     $post = get_post($post_id);
     foreach ($args as $key => $value) {
         if ('post_category' === $key || 'post_tags' === $key) {
             continue;
         }
         $this->assertSame($value, $post->{$key});
     }
     $this->assertSame(2, count(get_the_tags($post_id)));
     $this->assertSame(count($categories), count(wp_get_object_terms($post_id, 'category')));
     // it should be success to upload and should be attached to the post
     $attachment_id = $helper->add_media('http://placehold.jp/100x100.png', 'title', 'description', 'caption', false);
     $media = get_attached_media('image', $post_id);
     $this->assertSame($attachment_id, $media[$attachment_id]->ID);
 }
开发者ID:adaminfinitum,项目名称:advanced-csv-importer,代码行数:25,代码来源:test-wp-post-helper.php


示例7: get_photos

 private function get_photos()
 {
     $media = get_attached_media('image', $this->post->ID);
     $photos = array();
     foreach ($media as $object) {
         $photos[] = ['href' => wp_get_attachment_url($object->ID), 'caption' => wptexturize($object->post_content), 'credit' => $object->post_excerpt];
     }
     return $photos;
 }
开发者ID:TuftsDaily,项目名称:export-id-xml,代码行数:9,代码来源:class-export-id-xml-generator.php


示例8: getThumbs

 function getThumbs($post_id)
 {
     $attatchments = get_attached_media('image', $post_id);
     $attatchments_uris = array();
     foreach ($attatchments as $attch) {
         $attatchments_uris[] = wp_get_attachment_url($attch->ID);
     }
     return $attatchments_uris;
 }
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:9,代码来源:test-entity-creation-via-post-creation.php


示例9: process


//.........这里部分代码省略.........
                 // Page Template
                 if ('page' == $articleData['post_type'] and wp_all_import_is_update_cf('_wp_page_template', $this->options) and (!empty($this->options['page_template']) or "no" == $this->options['is_multiple_page_template'])) {
                     update_post_meta($pid, '_wp_page_template', "no" == $this->options['is_multiple_page_template'] ? $page_template[$i] : $this->options['page_template']);
                 }
                 // [featured image]
                 $is_allow_import_images = apply_filters('wp_all_import_is_allow_import_images', false, $articleData['post_type']);
                 if (!empty($uploads) and false === $uploads['error'] and ($articleData['post_type'] == "product" and class_exists('PMWI_Plugin') or $is_allow_import_images) and (empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or $this->options['update_all_data'] == "no" and $this->options['is_update_images'])) {
                     if (!empty($images_bundle)) {
                         $is_show_add_new_images = apply_filters('wp_all_import_is_show_add_new_images', true, $post_type[$i]);
                         foreach ($images_bundle as $slug => $bundle_data) {
                             $featured_images = $bundle_data['files'];
                             $option_slug = $slug == 'pmxi_gallery_image' ? '' : $slug;
                             if (!empty($featured_images[$i])) {
                                 $targetDir = $uploads['path'];
                                 $targetUrl = $uploads['url'];
                                 $logger and call_user_func($logger, __('<b>IMAGES:</b>', 'wp_all_import_plugin'));
                                 if (!@is_writable($targetDir)) {
                                     $logger and call_user_func($logger, sprintf(__('<b>ERROR</b>: Target directory %s is not writable', 'wp_all_import_plugin'), $targetDir));
                                 } else {
                                     require_once ABSPATH . 'wp-admin/includes/image.php';
                                     $success_images = false;
                                     $gallery_attachment_ids = array();
                                     $imgs = array();
                                     $featured_delim = "yes" == $this->options[$option_slug . 'download_images'] ? $this->options[$option_slug . 'download_featured_delim'] : $this->options[$option_slug . 'featured_delim'];
                                     $line_imgs = explode("\n", $featured_images[$i]);
                                     if (!empty($line_imgs)) {
                                         foreach ($line_imgs as $line_img) {
                                             $imgs = array_merge($imgs, !empty($featured_delim) ? str_getcsv($line_img, $featured_delim) : array($line_img));
                                         }
                                     }
                                     // keep existing and add newest images
                                     if (!empty($articleData['ID']) and $this->options['is_update_images'] and $this->options['update_images_logic'] == "add_new" and $this->options['update_all_data'] == "no" and $is_show_add_new_images) {
                                         $logger and call_user_func($logger, __('- Keep existing and add newest images ...', 'wp_all_import_plugin'));
                                         $attachment_imgs = get_attached_media('image', $pid);
                                         if ($post_type[$i] == "product") {
                                             $gallery_attachment_ids = array_filter(explode(",", get_post_meta($pid, '_product_image_gallery', true)));
                                         }
                                         if ($attachment_imgs) {
                                             foreach ($attachment_imgs as $attachment_img) {
                                                 $post_thumbnail_id = get_post_thumbnail_id($pid);
                                                 if (empty($post_thumbnail_id) and $this->options[$option_slug . 'is_featured']) {
                                                     set_post_thumbnail($pid, $attachment_img->ID);
                                                 } elseif (!in_array($attachment_img->ID, $gallery_attachment_ids) and $post_thumbnail_id != $attachment_img->ID) {
                                                     $gallery_attachment_ids[] = $attachment_img->ID;
                                                 }
                                             }
                                             $success_images = true;
                                         }
                                         if (!empty($gallery_attachment_ids)) {
                                             foreach ($gallery_attachment_ids as $aid) {
                                                 do_action($slug, $pid, $aid, wp_get_attachment_url($aid), 'update_images');
                                             }
                                         }
                                     }
                                     if (!empty($imgs)) {
                                         if ($this->options[$option_slug . 'set_image_meta_title'] and !empty($image_meta_titles_bundle[$slug])) {
                                             $img_titles = array();
                                             $line_img_titles = explode("\n", $image_meta_titles_bundle[$slug][$i]);
                                             if (!empty($line_img_titles)) {
                                                 foreach ($line_img_titles as $line_img_title) {
                                                     $img_titles = array_merge($img_titles, !empty($this->options[$option_slug . 'image_meta_title_delim']) ? str_getcsv($line_img_title, $this->options[$option_slug . 'image_meta_title_delim']) : array($line_img_title));
                                                 }
                                             }
                                         }
                                         if ($this->options[$option_slug . 'set_image_meta_caption'] and !empty($image_meta_captions_bundle[$slug])) {
                                             $img_captions = array();
开发者ID:k-hasan-19,项目名称:wp-all-import,代码行数:67,代码来源:record.php


示例10: getIncidentMediaList

 /**
  * Returns an HTML structure containing nested lists and list items
  * referring to any media attached to the given post ID.
  *
  * @param int $post_id The post ID from which to fetch attached media.
  *
  * @uses WP_Buoy_Alert::getIncidentMediaHtml()
  *
  * @return string HTML ready for insertion into an `<ul>` element.
  */
 private static function getIncidentMediaList($post_id)
 {
     $html = '';
     $posts = array('video' => get_attached_media('video', $post_id), 'image' => get_attached_media('image', $post_id), 'audio' => get_attached_media('audio', $post_id));
     foreach ($posts as $type => $set) {
         $html .= '<li class="' . esc_attr($type) . ' list-group">';
         $html .= '<div class="list-group-item">';
         $html .= '<h4 class="list-group-item-heading">';
         switch ($type) {
             case 'video':
                 $html .= esc_html('Video attachments', 'buoy');
                 break;
             case 'image':
                 $html .= esc_html('Image attachments', 'buoy');
                 break;
             case 'audio':
                 $html .= esc_html('Audio attachments', 'buoy');
                 break;
         }
         $html .= ' <span class="badge">' . count($set) . '</span>';
         $html .= '</h4>';
         $html .= '<ul>';
         foreach ($set as $post) {
             $html .= '<li id="incident-media-' . $post->ID . '" class="list-group-item">';
             $html .= '<h5 class="list-group-item-header">' . esc_html($post->post_title) . '</h5>';
             $html .= self::getIncidentMediaHtml($type, $post->ID);
             $html .= '<p class="list-group-item-text">';
             $html .= sprintf(esc_html_x('uploaded %1$s ago', 'Example: uploaded 5 mins ago', 'buoy'), human_time_diff(strtotime($post->post_date_gmt)));
             $u = get_userdata($post->post_author);
             $html .= ' ' . sprintf(esc_html_x('by %1$s', 'a byline, like "written by Bob"', 'buoy'), $u->display_name);
             $html .= '</p>';
             $html .= '</li>';
         }
         $html .= '</ul>';
         $html .= '</div>';
         $html .= '</li>';
     }
     return $html;
 }
开发者ID:anhquan0412,项目名称:better-angels,代码行数:49,代码来源:class-buoy-alert.php


示例11: get_posts

$slidePosts = get_posts(array('numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_parent' => $id, 'post_type' => 'Micro Slider'));
?>

<div id="all-slides">
<?php 
// wp_delete_post(431, true);
//+проверка на пустую картинку
?>
 <?php 
// echo "<pre>";
// print_r($slidePosts);
// echo "</pre>";
?>
	<?php 
foreach ($slidePosts as $slider) {
    $attach = get_attached_media('image', $slider->ID);
    $cleanedObject = reset($attach);
    // print_r(reset($attach)->guid);
    //echo "<img src='" . reset($attach)->guid . "' />" . "<br />";
    ?>

	<div class="single-slide" id="item-<?php 
    echo $cleanedObject->post_parent;
    ?>
">
		<div class="image">
			<img src="<?php 
    echo $cleanedObject->guid;
    ?>
" />
		</div> 
开发者ID:dev-wl,项目名称:torani,代码行数:31,代码来源:edit.php


示例12: _s_get_post_image_uri

/**
 * Return an image URI, no matter what.
 *
 * @param  string  $size  The image size you want to return.
 * @return string         The image URI.
 */
function _s_get_post_image_uri($size = 'thumbnail')
{
    // If featured image is present, use that.
    if (has_post_thumbnail()) {
        $featured_image_id = get_post_thumbnail_id(get_the_ID());
        $media = wp_get_attachment_image_src($featured_image_id, $size);
        if (is_array($media)) {
            return current($media);
        }
    }
    // Check for any attached image.
    $media = get_attached_media('image', get_the_ID());
    $media = current($media);
    // Set up default image path.
    $media_url = get_stylesheet_directory_uri() . '/assets/images/placeholder.png';
    // If an image is present, then use it.
    if (is_array($media) && 0 < count($media)) {
        $media_url = 'thumbnail' === $size ? wp_get_attachment_thumb_url($media->ID) : wp_get_attachment_url($media->ID);
    }
    return $media_url;
}
开发者ID:allisonplus,项目名称:wd_s,代码行数:27,代码来源:template-tags.php


示例13: test_get_attached_images

	/**
	 * @ticket 22960
	 */
	function test_get_attached_images() {
		$post_id = $this->factory->post->create();
		$attachment_id = $this->factory->attachment->create_object( $this->img_name, $post_id, array(
			'post_mime_type' => 'image/jpeg',
			'post_type' => 'attachment'
		) );

		$images = get_attached_media( 'image', $post_id );
		$this->assertEquals( $images, array( $attachment_id => get_post( $attachment_id ) ) );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:13,代码来源:media.php


示例14: custom_video_shortcode

function custom_video_shortcode($attr, $content = '')
{
    global $content_width;
    $post_id = get_post() ? get_the_ID() : 0;
    static $instances = 0;
    $instances++;
    /**
     * Override the default video shortcode.
     *
     * @since 3.7.0
     *
     * @param null              Empty variable to be replaced with shortcode markup.
     * @param array  $attr      Attributes of the shortcode.
     * @param string $content   Shortcode content.
     * @param int    $instances Unique numeric ID of this video shortcode instance.
     */
    $html = apply_filters('wp_video_shortcode_override', '', $attr, $content, $instances);
    if ('' !== $html) {
        return $html;
    }
    $video = null;
    $default_types = wp_get_video_extensions();
    $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'height' => 1080, 'width' => empty($content_width) ? 1920 : $content_width, 'size' => '');
    foreach ($default_types as $type) {
        $defaults_atts[$type] = '';
    }
    $atts = shortcode_atts($defaults_atts, $attr, 'video');
    extract($atts);
    $w = $width;
    $h = $height;
    if (is_admin() && $width > 600) {
        $w = 1920;
    } elseif (!is_admin() && $w > $defaults_atts['width']) {
        $w = $defaults_atts['width'];
    }
    if ($w < $width) {
        $height = round($h * $w / $width);
    }
    $width = $w;
    $primary = false;
    if (!empty($src)) {
        $type = wp_check_filetype($src, wp_get_mime_types());
        if (!in_array(strtolower($type['ext']), $default_types)) {
            return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($src), esc_html($src));
        }
        $primary = true;
        array_unshift($default_types, 'src');
    } else {
        foreach ($default_types as $ext) {
            if (!empty(${$ext})) {
                $type = wp_check_filetype(${$ext}, wp_get_mime_types());
                if (strtolower($type['ext']) === $ext) {
                    $primary = true;
                }
            }
        }
    }
    if (!$primary) {
        $videos = get_attached_media('video', $post_id);
        if (empty($videos)) {
            return;
        }
        $video = reset($videos);
        $src = wp_get_attachment_url($video->ID);
        if (empty($src)) {
            return;
        }
        array_unshift($default_types, 'src');
    }
    $library = apply_filters('wp_video_shortcode_library', 'mediaelement');
    /*if ( 'mediaelement' === $library && did_action( 'init' ) ) {
                    wp_enqueue_style( 'wp-mediaelement' );
                    wp_enqueue_script( 'wp-mediaelement' );
            }
    
            /*$atts = array(
                    'class'    => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ),
                    'id'       => sprintf( 'video-%d-%d', $post_id, $instances ),
                    'width'    => absint( $width ),
                    'height'   => absint( $height ),
                    'poster'   => esc_url( $poster ),
                    'loop'     => $loop,
                    'autoplay' => $autoplay,
                    'preload'  => $preload,
            );*/
    // These ones should just be omitted altogether if they are blank
    foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) {
        if (empty($atts[$a])) {
            unset($atts[$a]);
        }
    }
    $attr_strings = array();
    foreach ($atts as $k => $v) {
        $attr_strings[] = $k . '="' . esc_attr($v) . '"';
    }
    $html .= '<video id="videoplayer" class="video-js vjs-mnml ' . $size . '" controls="controls" data-setup>';
    $fileurl = '';
    $source = '<source type="%s" src="%s" />';
    foreach ($default_types as $fallback) {
        if (!empty(${$fallback})) {
//.........这里部分代码省略.........
开发者ID:nicowesse,项目名称:nicowesse,代码行数:101,代码来源:functions.php


示例15: artempol_get_posts

}
// News
$news = artempol_get_posts('news-list', array('category_name' => 'news', 'posts_per_page' => get_theme_mod('news-main-number', 2)), array('image', 'title', 'url', 'date', 'content'));
if ($news) {
    $heading = artempol_container(array('tag' => 'h2', 'content' => __('News', 'artempol')));
    $news = artempol_container(array('tag' => 'div', 'content' => $heading . $news, 'class' => 'content_wrap news padding_tb_20 wow fadeInUp'));
    echo $news;
}
// Colored_blocks
$colored_blocks = artempol_get_posts('colored', array('category_name' => 'colorblocks'), array('counter', 'title', 'content'));
if ($colored_blocks) {
    $colored_blocks = artempol_container(array('tag' => 'div', 'content' => $colored_blocks, 'class' => 'content_wrap clearfix padding_tb_10 wow fadeInUp'));
    echo $colored_blocks;
}
// Achievements
$images = get_attached_media('image', get_theme_mod('achievements-page'));
$achievements = '';
foreach ($images as $post) {
    $achievements .= artempol_get_post($post, 'achievements', array('achievement_image', 'achievement_url', 'achievement_margin'));
}
if ($achievements) {
    $achievements = artempol_container(array('tag' => 'ul', 'content' => $achievements, 'class' => 'slides'));
    $achievements = artempol_container(array('tag' => 'div', 'content' => $achievements, 'class' => 'slider-achieve flexslider wow fadeInUp'));
    $achievements = artempol_container(array(), 'line') . $achievements;
    echo $achievements;
}
// Services
$services = get_post(get_theme_mod('services-page'));
if ($services) {
    $services = artempol_get_post($services, 'services', array('title', 'content'));
    echo $services;
开发者ID:valerol,项目名称:artempol,代码行数:31,代码来源:page-main.php


示例16: test_file_list_field_after_value_update

 public function test_file_list_field_after_value_update()
 {
     $images = get_attached_media('image', $this->post_id);
     $this->assertEquals($images, array($this->attachment_id => get_post($this->attachment_id), $this->attachment_id2 => get_post($this->attachment_id2)));
     update_post_meta($this->post_id, $this->text_type_field['id'], array($this->attachment_id => get_permalink($this->attachment_id), $this->attachment_id2 => get_permalink($this->attachment_id2)));
     $this->assertHTMLstringsAreEqual(sprintf('<input type="hidden" class="cmb2-upload-file cmb2-upload-list" name="field_test_field" id="field_test_field" value="" size="45" data-previewsize=\'[50,50]\' data-queryargs=\'\'/><input type="button" class="cmb2-upload-button button cmb2-upload-list" name="" id="" value="%7$s"/><p class="cmb2-metabox-description">This is a description</p><ul id="field_test_field-status" class="cmb2-media-status cmb-attach-list"><li class="file-status"><span>%6$s <strong>?attachment_id=%1$d</strong></span>&nbsp;&nbsp; (<a href="%3$s/?attachment_id=%1$d" target="_blank" rel="external">%4$s</a> / <a href="#" class="cmb2-remove-file-button">%5$s</a>)<input type="hidden" name="field_test_field[%1$d]" id="filelist-%1$d" value="%3$s/?attachment_id=%1$d" data-id=\'%1$d\'/></li><li class="file-status"><span>%6$s <strong>?attachment_id=%2$d</strong></span>&nbsp;&nbsp; (<a href="%3$s/?attachment_id=%2$d" target="_blank" rel="external">%4$s</a> / <a href="#" class="cmb2-remove-file-button">%5$s</a>)<input type="hidden" name="field_test_field[%2$d]" id="filelist-%2$d" value="%3$s/?attachment_id=%2$d" data-id=\'%2$d\'/></li></ul>', $this->attachment_id, $this->attachment_id2, site_url(), __('Download', 'cmb2'), __('Remove', 'cmb2'), __('File:', 'cmb2'), __('Add or Upload Files', 'cmb2')), $this->capture_render(array($this->get_field_type_object('file_list'), 'render')));
     delete_post_meta($this->post_id, $this->text_type_field['id']);
 }
开发者ID:Dovahkiin1991,项目名称:CMB2,代码行数:8,代码来源:test-cmb-types.php


示例17: do_attached_media

 /**
  * Gets media attached to the post.  Then, uses the WordPress [audio] or [video] shortcode to handle 
  * the HTML output of the media.
  *
  * @since  1.6.0
  * @access public
  * @return void
  */
 public function do_attached_media()
 {
     /* Gets media attached to the post by mime type. */
     $attached_media = get_attached_media($this->type, $this->args['post_id']);
     /* If media is found. */
     if (!empty($attached_media)) {
         /* Get the first attachment/post object found for the post. */
         $post = array_shift($attached_media);
         /* Gets the URI for the attachment (the media file). */
         $url = wp_get_attachment_url($post->ID);
         /* Run the media as a shortcode using WordPress' built-in [audio] and [video] shortcodes. */
         $this->media = do_shortcode("[{$this->type} src='{$url}']");
     }
 }
开发者ID:highergroundstudio,项目名称:hybrid-core,代码行数:22,代码来源:hybrid-media-grabber.php


示例18: et_gallery_images

    function et_gallery_images()
    {
        $output = $images_ids = '';
        if (function_exists('get_post_galleries')) {
            $galleries = get_post_galleries(get_the_ID(), false);
            if (empty($galleries)) {
                return false;
            }
            foreach ($galleries as $gallery) {
                if (isset($gallery['ids'])) {
                    // Grabs all attachments ids from one or multiple galleries in the post
                    $images_ids .= ('' !== $images_ids ? ',' : '') . $gallery['ids'];
                } else {
                    $image_ids = false;
                    // If user doesn't define ids of images on galleries, get attached media
                    $attached_media = get_attached_media('image', get_the_id());
                }
            }
            if ($images_ids) {
                $attachments_ids = explode(',', $images_ids);
            } elseif (isset($attached_media) && is_array($attached_media) && !empty($attached_media)) {
                $attachments_ids = wp_list_pluck($attached_media, 'ID');
            } else {
                $attachments_ids = false;
            }
            if (!$attachments_ids) {
                // Print no gallery found message
                ?>
			<div class="et_pb_module et_pb_slider et_pb_slider_fullwidth_off et_pb_bg_layout_light gallery-not-found">
				<div class="et_pb_slides">
					<div class="et_pb_slide et_pb_bg_layout_light et_pb_media_alignment_center et-pb-active-slide" style="background-color:#ffffff;">
						<div class="et_pb_container clearfix">
							<div class="et_pb_slide_description">
								<h2><?php 
                _e('No Gallery Found', 'Divi');
                ?>
</h2>
								<div class="et_pb_slide_content">
									<p><?php 
                _e('No items found', 'Divi');
                ?>
</p>
								</div>
							</div> <!-- .et_pb_slide_description -->
						</div> <!-- .et_pb_container -->
					</div> <!-- .et_pb_slide -->
				</div> <!-- .et_pb_slides -->
			</div>
			<?php 
                return;
            }
            // Removes duplicate attachments ids
            $attachments_ids = array_unique($attachments_ids);
        } else {
            $pattern = get_shortcode_regex();
            preg_match("/{$pattern}/s", get_the_content(), $match);
            $atts = shortcode_parse_atts($match[3]);
            if (isset($atts['ids'])) {
                $attachments_ids = explode(',', $atts['ids']);
            } else {
                return false;
            }
        }
        $slides = '';
        foreach ($attachments_ids as $attachment_id) {
            $attachment_attributes = wp_get_attachment_image_src($attachment_id, 'et-pb-post-main-image-fullwidth');
            $attachment_image = !is_single() ? $attachment_attributes[0] : wp_get_attachment_image($attachment_id, 'et-pb-portfolio-image');
            if (!is_single()) {
                $slides .= sprintf('<div class="et_pb_slide" style="background: url(%1$s);"></div>', esc_attr($attachment_image));
            } else {
                $full_image = wp_get_attachment_image_src($attachment_id, 'full');
                $full_image_url = $full_image[0];
                $attachment = get_post($attachment_id);
                $slides .= sprintf('<li class="et_gallery_item">
					<a href="%1$s" title="%3$s">
						<span class="et_portfolio_image">
							%2$s
							<span class="et_overlay"></span>
						</span>
					</a>
				</li>', esc_url($full_image_url), $attachment_image, esc_attr($attachment->post_title));
            }
        }
        if (!is_single()) {
            $output = '<div class="et_pb_slider et_pb_slider_fullwidth_off et_pb_gallery_post_type">
				<div class="et_pb_slides">
					%1$s
				</div>
			</div>';
        } else {
            $output = '<ul class="et_post_gallery clearfix">
				%1$s
			</ul>';
        }
        printf($output, $slides);
    }
开发者ID:Lumbe,项目名称:dev_servus,代码行数:96,代码来源:functions.php


示例19: ajax_attach_image_post

/**
 * @package grab-image
 * ajax function to attach image
 */
function ajax_attach_image_post()
{
    $id = intval($_REQUEST['id']);
    $post = get_post($id);
    if (empty($post)) {
        echo 'Wrong post ID';
        wp_die();
    }
    // call helper class
    $helper = new grabimage_helper();
    // extract image tag from post content
    $array = $helper->extract_image($post->post_content, false);
    $search = $replace = [];
    $count = 0;
    if (is_array($array) && count($array) > 0) {
        foreach ($array as $tag => $url) {
            // get attachment ID from url
            $attachment_id = $helper->get_attachment_id($url);
            if (empty($attachment_id)) {
                continue;
            }
            // get post attachment
            $attachments = get_attached_media('image', $post->ID);
            // ignore if image was attachment
            if (isset($attachments[$attachment_id])) {
                continue;
            }
            wp_update_post(['ID' => $attachment_id, 'post_parent' => $post->ID]);
            // search a|img tag
            $search[] = $tag;
            // replace with
            $image = wp_get_attachment_image_src($attachment_id, 'full');
            $id = $attachment_id;
            $src = $image[0];
            $replace[] = "<a href=\"{$src}\" rel=\"attachment wp-att-{$id}\">" . "<img class=\"alignnone size-full wp-image-{$id}\" src=\"{$src}\" alt=\"{$post->post_title}\" />" . "</a>";
            echo "success ; {$url} ; {$attachment_id} <br/>";
        }
        // update post data
        if (count($search) > 0 && count($replace) > 0) {
            $post_content = str_replace($search, $replace, $post->post_content);
            $my_post = ['ID' => $post->ID, 'post_content' => $post_content];
            wp_update_post($my_post);
        }
        $count = count($search);
    }
    echo 'Attached ' . $count . ' image';
    wp_die();
}
开发者ID:benjaminmedia,项目名称:wp-grab-image,代码行数:52,代码来源:grab-image.php


示例20: wpdm_sample_audio_single

/**
 * @usage Create sample audio player for link template
 * @param $package
 * @param bool $return
 * @return mixed|string|void
 */
function wpdm_sample_audio_single($package, $ret 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_attachment函数代码示例发布时间:2022-05-15
下一篇:
PHP get_attached_file函数代码示例发布时间: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