如何获取元框自定义图像大小

时间:2016-03-26 12:24:49

标签: php wordpress meta meta-boxes

我需要调用这个大小... add_image_size(' sami_post_standard',760,400,true);在元框中 .................................................. ............ .................................................. ............

  

此元框代码

/**
     * Post Type Gallery
     */

    $meta_boxes['metabox-post-gallery'] = array(
        'id'         => 'metabox-post-gallery',
        'title'      => __( 'Gallery Settings', 'sami' ),
        'pages'      => array( 'post', ),
        'context'    => 'normal',
        'priority'   => 'high',
        'show_names' => true,
        'fields'     => array(
            array(
                'name'         => __( 'Slider Images', 'sami' ),
                'desc'         => __( 'Upload Your Gallery Slider images.', 'sami' ),
                'id'           => $prefix . 'gallery_slider',
                'type'         => 'file_list',
                'preview_size' => array( 100, 100 ),
            ),
        ),
    );
/////////////////////////
in single.php file call
/////////////////////////
$gallery_slider = get_post_meta( $post->ID, 'sami_gallery_slider', true );

            <div class="slider_post">
                <div class="post_silder">
                    <ul id="post-slid-post">
                        <?php
                            foreach ( $gallery_slider as $gallery_slider ) {
                                echo "<li>";
                                echo '<div class="item"><img src="'. esc_url($gallery_slider) .'" alt="'. esc_attr(get_the_title()) .'"></div>';
                                echo "</li>";
                            }
                        ?>
                    </ul>
                </div>
            </div>

1 个答案:

答案 0 :(得分:0)

  

这是解决方案

<?php
        if ( $gallery_sliders ) {
          foreach ( $gallery_sliders as $attachment_id => $img_full_url ) {
            echo "<li>";
            echo '<div class="item">'. $full = wp_get_attachment_link($attachment_id, 'ashmawi_post_standard'); echo esc_url($full[0]) .'</div>';
            echo "</li>";
            }
        }
  ?>