本文整理汇总了PHP中get_post_galleries_images函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_galleries_images函数的具体用法?PHP get_post_galleries_images怎么用?PHP get_post_galleries_images使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_galleries_images函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: from_gallery
/**
* If a gallery is detected, then get all the images from it.
*/
static function from_gallery($post_id)
{
$images = array();
$post = get_post($post_id);
if (!empty($post->post_password)) {
return $images;
}
$permalink = get_permalink($post->ID);
$gallery_images = get_post_galleries_images($post->ID, false);
foreach ($gallery_images as $galleries) {
foreach ($galleries as $src) {
list($raw_src) = explode('?', $src);
// pull off any Query string (?w=250)
$raw_src = wp_specialchars_decode($raw_src);
// rawify it
$raw_src = esc_url_raw($raw_src);
// clean it
$images[] = array('type' => 'image', 'from' => 'gallery', 'src' => $raw_src, 'href' => $permalink);
}
}
return $images;
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:25,代码来源:class.jetpack-post-images.php
示例2: test_post_galleries_images
/**
* @ticket 22960
*/
function test_post_galleries_images() {
$ids1 = array();
$ids1_srcs = array();
foreach ( range( 1, 3 ) as $i ) {
$attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
wp_update_attachment_metadata( $attachment_id, $this->img_dimensions );
$ids1[] = $attachment_id;
$ids1_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
}
$ids2 = array();
$ids2_srcs = array();
foreach ( range( 4, 6 ) as $i ) {
$attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment'
) );
wp_update_attachment_metadata( $attachment_id, $this->img_dimensions );
$ids2[] = $attachment_id;
$ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
}
$ids1_joined = join( ',', $ids1 );
$ids2_joined = join( ',', $ids2 );
$blob =<<<BLOB
[gallery ids="$ids1_joined"]
[gallery ids="$ids2_joined"]
BLOB;
$post_id = $this->factory->post->create( array( 'post_content' => $blob ) );
$srcs = get_post_galleries_images( $post_id );
$this->assertEquals( $srcs, array( $ids1_srcs, $ids2_srcs ) );
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:40,代码来源:media.php
示例3: hybrid_get_gallery_image_count
/**
* Returns the number of images displayed by the gallery or galleries in a post.
*
* @since 1.6.0
* @access public
* @return int
*/
function hybrid_get_gallery_image_count()
{
/* Set up an empty array for images. */
$images = array();
/* Get the images from all post galleries. */
$galleries = get_post_galleries_images();
/* Merge each gallery image into a single array. */
foreach ($galleries as $gallery_images) {
$images = array_merge($images, $gallery_images);
}
/* If there are no images in the array, just grab the attached images. */
if (empty($images)) {
$images = get_posts(array('fields' => 'ids', 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1));
}
/* Return the count of the images. */
return count($images);
}
开发者ID:RA2WP,项目名称:RA2WP,代码行数:24,代码来源:post-formats.php
示例4: wpmc_get_galleries_images
function wpmc_get_galleries_images($force = false)
{
if ($force) {
delete_transient("galleries_images");
$galleries_images = null;
} else {
$galleries_images = get_transient("galleries_images");
}
if (!$galleries_images) {
global $wpdb;
$galleries_images = array();
$posts = $wpdb->get_col("SELECT id FROM {$wpdb->posts} WHERE post_type != 'attachment' AND post_status != 'inherit'");
foreach ($posts as $post) {
$galleries = get_post_galleries_images($post);
foreach ($galleries as $gallery) {
foreach ($gallery as $image) {
array_push($galleries_images, $image);
}
}
}
set_transient("galleries_images", $galleries_images, 60 * 60 * 2);
}
return $galleries_images;
}
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:24,代码来源:wp-media-cleaner.php
示例5: jkl_get_gallery_count
/**
* Post Format: Gallery (Count)
*
* Count the number of images in the Gallery (or Galleries)
*/
function jkl_get_gallery_count()
{
$images = get_post_galleries_images();
// from WordPress 3.6.0
$total_galleries[] = count($images);
$total_galleries[] = count($images, COUNT_RECURSIVE) - $total_galleries[0];
$image = reset($images);
return $total_galleries;
}
开发者ID:jekkilekki,项目名称:theme-jkl,代码行数:14,代码来源:template-tags.php
示例6: wpmc_get_galleries_images
function wpmc_get_galleries_images($force = false)
{
if ($force) {
delete_transient("wpmc_galleries_images");
$galleries_images = null;
} else {
$galleries_images = get_transient("wpmc_galleries_images");
}
if (!$galleries_images) {
global $wpdb;
$galleries_images = array();
$posts = $wpdb->get_col("SELECT id FROM {$wpdb->posts} WHERE post_type != 'attachment' AND post_status != 'inherit'");
foreach ($posts as $post) {
$galleries = get_post_galleries_images($post);
foreach ($galleries as $gallery) {
foreach ($gallery as $image) {
array_push($galleries_images, $image);
}
}
}
$post_galleries = get_posts(array('tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-gallery'), 'operator' => 'IN'))));
foreach ((array) $post_galleries as $gallery_post) {
$arrImages = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $gallery_post->ID);
if ($arrImages) {
foreach ((array) $arrImages as $image_post) {
array_push($galleries_images, $image_post->guid);
}
}
}
wp_reset_postdata();
set_transient("wpmc_galleries_images", $galleries_images, 60 * 60 * 2);
}
return $galleries_images;
}
开发者ID:fronbow,项目名称:wp-media-cleaner,代码行数:34,代码来源:wp-media-cleaner.php
示例7: the_ID
*/
?>
<article id="post-<?php
the_ID();
?>
" <?php
post_class("fullpage");
?>
>
<div class="entry-content section">
<?php
// Retrieve all galleries of this post
$galleries = get_post_galleries_images($post);
// Loop through all galleries found
foreach ($galleries as $gallery) {
?>
<div class="slide">
<?php
// Loop through each image in each gallery
foreach ($gallery as $image) {
echo '<div class="single-img">';
echo '<img src="';
echo $image;
echo '">';
echo '</div>';
}
?>
开发者ID:eelfonik,项目名称:bb,代码行数:31,代码来源:content-page.php
示例8: courage_ui_gallery_carousel
function courage_ui_gallery_carousel($content)
{
global $post;
// Only do this on singular items
if (!is_singular()) {
return $content;
}
// Make sure the post has a gallery in it
if (!has_shortcode($post->post_content, 'gallery')) {
return $content;
}
$find_gallery = substr($content, strpos($content, "[gallery"));
// Get our new content without the gallery
$new_content = str_replace($find_gallery, '', $content);
// Remove the gallery
unset($content);
// Now replace it with our new content
$output = $new_content;
// Retrieve all galleries of this post
$galleries = get_post_galleries_images($post);
$item = 0;
$output .= '<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">';
// Remove the previous gallery
// unset($content);
$output .= '<div class="carousel-inner" role="listbox">';
// Loop through all galleries found
$output .= '<ol class="carousel-indicators">';
foreach ($galleries as $gallery) {
for ($i = 0; $i < count($gallery); $i++) {
if ($i == 0) {
$output .= '<li data-target="#carousel-example-generic" data-slide-to="' . $i . '" class="active"></li>';
} else {
$output .= '<li data-target="#carousel-example-generic" data-slide-to="' . $i . '"></li>';
}
}
$output .= '</ol>';
// Loop through each image in each gallery
foreach ($gallery as $image) {
if ($item == 0) {
$output .= '<div class="item active">';
$output .= '<img src="' . $image . '" alt="...">';
$output .= '<div class="carousel-caption">';
$output .= '';
$output .= '</div>';
$output .= '</div>';
} else {
$output .= '<div class="item">';
$output .= '<img src="' . $image . '" alt="...">';
$output .= '<div class="carousel-caption">';
$output .= '';
$output .= '</div>';
$output .= '</div>';
}
$item++;
}
}
$output .= '</div>';
$output .= '<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">';
$output .= '<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>';
$output .= '<span class="sr-only">Previous</span>';
$output .= '</a>';
$output .= '<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">';
$output .= '<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>';
$output .= '<span class="sr-only">Next</span>';
$output .= '</a>';
$output .= '</div>';
// Append our image list to the content of our post
$content .= $output;
return $content;
}
开发者ID:picpen,项目名称:courage-thru-christ,代码行数:70,代码来源:functions.php
注:本文中的get_post_galleries_images函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论