• WP_Customize_Media_Control
    I used WP_Customize_Media_Control to control the image height and width of my image and the output is not proportionate to hero support height and width. What ami missing out here?

    // Hero Image
    $wp_customize->add_setting( 'hero_image' ,
    array(
    'transport' => 'refresh',
    'sanitize_callback' => 'absint',
    )
    );
    $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize , 'hero_image' ,
    array(
    'label' => __( 'Hero Image', 'ize-theme' ),
    'description' => __('Upload hero image', 'ize-theme'),
    'settings' => 'hero_image',
    'section' => 'hero_section',
    'mime_type' => 'image',
    ))
    );
    add_theme_support(
    'hero_image',
    array(
    'height' => 574,
    'width' => 780,
    'flex-width' => true,
    'flex-height' => true,
    )
    );
    $ize_theme_hero_image = get_theme_mod( "hero_image" );
    <?php
    if ( !empty($ize_theme_hero_image) ) {
    echo wp_get_attachment_image( $ize_theme_hero_image, 'hero_image' ) ;
    } ?>
    • This topic was modified 3 years, 7 months ago by bcworkz. Reason: code fixed
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter shaibustephen

    (@shaibustephen)

    Indeed. I have varying image sized created but issue is that it does not display the actual custom image size for the setting rather displaying only the full image size. how can i get this corrected?

    Moderator bcworkz

    (@bcworkz)

    “hero_image” is not a default theme support item. It could be something implemented by your theme. Unless the theme takes the passed data and somehow uses it when the theme initializes, you support data is possibly ignored.

    Similarly, “hero_image” is not a default image size. It could be something your theme implements. If so, you also need to alter the registered image size. If “hero_image” size is not registered at all, you’ll need to do so. The new sizes will not affect existing images, only newly uploaded.

    Theme support and attachment image sizes are not interrelated. You need to address each individually. For specifics on what your theme may or might not do, I direct you to the theme’s dedicated support channel where its devs and expert users can better help you.

    Thread Starter shaibustephen

    (@shaibustephen)

    if that is so, of what use is the support I have above

    Moderator bcworkz

    (@bcworkz)

    I don’t know, it may be of no use, or meaningful to your theme.

    The “supports” data is merely a registry of sorts, a common place to store data. You can put anything you like in it, but unless there is also code to look at the data and do something about it, nothing happens with it. Core code looks for certain values and does something with it. “hero_image” isn’t one of them. If it’s something your theme or plugin looks for, then great. If not, it serves no purpose.

    Its intent is to let themes tell core, “I support this feature” so core can implement certain features. Since anything can store anything with “supports” data, it could be used for other purposes, but core will not help in that regard.
    https://developer.www.ads-software.com/reference/functions/add_theme_support/#parameters

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need help on WP_Customize_Media_Control’ is closed to new replies.