Kirki: image field inside repeater

Created on 20 Feb 2018  ·  6Comments  ·  Source: kirki-framework/kirki

Issue description:

hey so im having a problem with image inside the repeater so i have a text a link and an image both text and link work fine but image link doesn't echo well so I'm just asking how to get the output of an image inside a repeater
im folwing the same codes from the documentation

Version used:

latest ver from wp.org

Using theme_mods or options?

theme_mods

Code to reproduce the issue (config + field(s))

the same code from documentation link and text work fine but image doesn't help is much appreciated

All 6 comments

please guys i really need help

customizer code

stylethemes_Kirki::add_section( 'featured_boxes_section', array(
        'title'      => esc_attr__( 'Featured Boxes', 'consultme' ),
        'priority'   => 4,
        'panel' => 'theme_settings',
        'capability' => 'edit_theme_options',
    ));

    stylethemes_Kirki::add_field( 'consultme', array(
        'type'        => 'toggle',
        'settings'    => 'featured_boxes',
        'label'       => esc_attr__( 'Enable Featured Boxes', 'authentic' ),
        'section'     => 'featured_boxes_section',
        'default'     => false,
        'priority'    => 10,
    ) );

    stylethemes_Kirki::add_field( 'consultme', array(
        'type'        => 'image',
        'settings'    => 'featured_boxesimage',
        'label'       => esc_attr__( 'Enable Featured Boxes', 'authentic' ),
        'section'     => 'featured_boxes_section',
        'default'     => '',
        'priority'    => 1,
    ) );

    stylethemes_Kirki::add_field( 'consultme', array(
        'type'        => 'repeater',
        'label'       => esc_attr__( 'Featured Boxe', 'consultme' ),
        'section'     => 'featured_boxes_section',
        'priority'    => 3,
        'row_label' => array(
            'type' => 'text',
            'value' => esc_attr__('Featured Boxes', 'consultme' ),
        ),
        'settings'    => 'featured_boxes_repeater',
        'choices' => array(
            'limit' => 3
        ),
        'active_callback' => array(
            array(
                'setting'  => 'featured_boxes',
                'operator' => '==',
                'value'    => true,
                ),
        ),
        'default'     => array(
            array(
                'featured_boxe_title' => esc_attr__( 'Stories', 'consultme' ),
                'featured_boxe_link'  => esc_url('#', 'consultme'),
                'featured_boxe_img' => esc_url('#', 'consultme'),
            ),
            array(
                'featured_boxe_title' => esc_attr__( 'shop', 'consultme' ),
                'featured_boxe_link'  => esc_url('#', 'consultme'),
                'featured_boxe_img' => esc_url('#', 'consultme'),
            ),
            array(
                'featured_boxe_title' => esc_attr__( 'insta', 'consultme' ),
                'featured_boxe_link'  => esc_url('#', 'consultme'),
                'featured_boxe_img' => esc_url('#', 'consultme'),
            ),
        ),
        'fields' => array(
            'featured_boxe_title' => array(
                'type'        => 'text',
                'label'       => esc_attr__( 'Featured Boxe Title', 'consultme' ),
                'default'     => '',
            ),
            'featured_boxe_link' => array(
                'type'        => 'text',
                'label'       => esc_attr__( 'Featured Boxe Link', 'consultme' ),
                'default'     => '',
            ),
            'featured_boxe_img' => array(
                'type'        => 'image',
                'label'       => esc_attr__( 'Featured Boxes image', 'consultme' ),
                'description' => esc_attr__( 'Upload Featured Boxes image', 'consultme' ),
                'default'     => '',
            ),
        )
    ));

output code please click to zoom image
php3

ok so, i did find an answer here's in case someone looking for it use

<?php echo wp_get_attachment_url( $featured_box['featured_boxe_img'] ); ?>

@stylethemes I'm sorry I didn't see this one sooner.
unfortunately images inside repeaters save the ID instead of the URL. I'm glad you managed to find a solution to this... Yes, using wp_get_attachment_url() is the way to go 👍

Hi, I have a same problem echo image from repeater. I have only two fields in my project, image_client field and link_url field. Url field is working fine but image not.
Here is my code, if you can help me I appreciate it

`
my_config_kirki_add_field(

array(

    'type'        => 'repeater',

    'label'       => esc_html__( 'Repeater Control', 'kcdf' ),

    'section'     => 'clients_section',

    'row_label' => [

        'type'  => 'text',

        'value' => esc_html__( 'Client', 'kcdf' ),

    ],

    'button_label' => esc_html__('Add new Client (optional)', 'kcdf' ),

    'settings'     => 'clients_setting',

    'fields' => [

        'image_client' => [

            'type'        => 'image',

            'label'       => esc_html__( 'Client Image', 'kcdf' ),

            'description' => esc_attr__( 'Upload Client Image', 'kcdf' ),

        ],

        'link_url'  => [

            'type'        => 'text',

            'label'       => esc_html__( 'Client Link URL', 'kcdf' ),

            'description' => esc_html__( 'This will be the link URL of Client', 'kcdf' ),

        ],

    ]

)

);

`
also here is the code i want to display

`

$clients = get_theme_mod( 'clients_setting');
?>

        <div class="owl-carousel">
            <?php foreach( $clients as $client ) : ?>
            <div class="item">
                <div class="image-holder">
                    <a href="<?php echo $client['link_url']; ?>" target="_blank">
                        <?php echo wp_get_attachment_url( $client['image_client'] ); ?>
                    </a>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>

`

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  ·  5Comments

fastmarketo picture fastmarketo  ·  4Comments

2one2 picture 2one2  ·  3Comments

fakrulislam picture fakrulislam  ·  3Comments

MapSteps picture MapSteps  ·  6Comments