I am using the Atelier theme and WC Vendor Pro plugin. I am trying to edit the default templates provided by WC Vendors Pro to show a club background image into the default themes hero title bar, if it is present.
I have tried all sorts, but I am not so familiar with PHP and arrays so my testing has mainly come from looking at other code examples.
Default Theme Hero Image
if ( isset( $sf_options['default_page_heading_image'] ) ) {
$fancy_title_image = $sf_options['default_page_heading_image'];
}
if ( $fancy_title_image_url == "" && isset( $fancy_title_image ) && isset( $fancy_title_image['url'] ) ) {
$fancy_title_image_url = $fancy_title_image['url'];
}
if ( $fancy_title_image_url != "" ) {
$hero_styles[] = "background-image: url(" . esc_url($fancy_title_image_url) . ");";
}
Vendor Hero Image
$store_banner_src = wp_get_attachment_image_src( get_user_meta( $vendor_id,
'_wcv_store_banner_id', true ), 'full' );
if ( is_array( $store_banner_src ) ) {
$store_banner = "background-image: url(" . esc_url($store_banner_src[0]) . ");";
} else {
// Getting default banner
$default_banner_src = get_option( 'wcvendors_default_store_banner_src' );
$store_banner = "background-image: url(" . esc_url($default_banner_src) . ");";
}
Output Code
<div class="page-heading fancy-heading <?php echo esc_attr($page_heading_el_class); ?> clearfix <?php echo esc_attr($page_title_text_style); ?>-style fancy-image <?php echo esc_attr($page_heading_el_class); ?>" style="<?php echo implode('', $hero_styles); ?>" data-height="<?php echo esc_attr($page_title_height); ?>" data-img-width="<?php echo esc_attr($heading_img_width); ?>" data-img-height="<?php echo esc_attr($heading_img_height); ?>">
<span class="media-overlay"></span>
I have narrowed this down that the background-image URL is being dynamically inserted into the default title bar using $hero_styles
within a PHP implode
tag. This works correctly but I am now trying to add a Vendor default image or unique vendor image (if set) to overwrite this default title background image if you are viewing a vendor shop.
I think I have the correct lines of code added above, all be it a bit messy. I have tried to add $store_banner
after $hero_styles
seperated by a comma but this prevents any image loading.
I know I need to figure out how to use some sort of IF statement, but I am so confused already my head is hurting!
Please help!