WP Residence Help WP Residence Help

  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code Required, WpResidence 5.0 / WPResidence Media Header – Image Function

WPResidence Media Header – Image Function

278 views 0

1. Introduction to wpestate_header_image Function

The wpestate_header_image function is an important component in the WPResidence theme, responsible for generating and displaying header images across various page types. This function is typically located in the header-media-functions.php file.

2. Function Overview

Here’s the basic structure of the wpestate_header_image function:

function wpestate_header_image($image) {
global $post;
$paralax_header = wpresidence_get_option('wp_estate_paralax_header', '');
if (is_category() || is_tax() || is_archive()) {
echo wpestate_get_simple_header_image($image);
} elseif (isset($post->ID)) {
$header_data = wpestate_get_header_data($post->ID);
echo wpestate_get_custom_header_image($image, $header_data, $paralax_header);
} else {
echo wpestate_get_simple_header_image($image);
}
}

3. Step-by-Step Breakdown

3.1 Function Parameters

  • $image: The URL of the header image to be displayed.

3.2 Global Variables and Options

  • global $post: Accesses the current post object.
  • $paralax_header: Retrieves the parallax header setting from theme options.

3.3 Conditional Logic

  1. Checks if the current page is a category, taxonomy, or archive page:
    • If true, calls wpestate_get_simple_header_image($image)
  2. If not, checks if there’s a current post ID:
    • If true, retrieves custom header data and calls wpestate_get_custom_header_image($image, $header_data, $paralax_header)
  3. If neither condition is met:
    • Falls back to wpestate_get_simple_header_image($image)

4. Supporting Functions

4.1 wpestate_get_simple_header_image

This function generates a basic header image HTML:

function wpestate_get_simple_header_image($image) {
return '<div class="wpestate_header_image" style="background-image:url(' . esc_url($image) . ')"></div>';
}

4.2 wpestate_get_header_data

This function retrieves header data based on the post ID:

function wpestate_get_header_data($post_id) {
if (is_page_template('splash_page.php')) {
return wpestate_get_splash_page_data();
} else {
return wpestate_get_regular_page_data($post_id);
}
}

4.3 wpestate_get_custom_header_image

This function generates more complex header image HTML with additional features:

function wpestate_get_custom_header_image($image, $header_data, $paralax_header) {
$header_data = wpestate_apply_default_values($header_data);
$style = wpestate_get_header_style($image, $header_data);
$class = wpestate_get_header_class($header_data, $paralax_header);
$output = "<div class=\"" . esc_attr($class) . "\" style=\"" . esc_attr($style) . "\">";
$output .= wpestate_get_overlay_html($header_data);
$output .= wpestate_get_heading_html($header_data);
$output .= '</div>';
return $output;
}

5. Customization Options

5.1 Modifying Header Image Display

To change how header images are displayed, you can modify the wpestate_get_custom_header_image function. For example, to add a new element:

function wpestate_get_custom_header_image($image, $header_data, $paralax_header) {
// ... existing code ...
$output .= wpestate_get_heading_html($header_data);
$output .= '<div class="custom-header-element">' . esc_html__('Custom Content', 'wpresidence') . '</div>';
$output .= '</div>';
return $output;
}

5.2 Adding New Header Types

To add a new header type, you would need to:

  1. Create a new function to handle the new header type.
  2. Modify the wpestate_header_image function to include your new header type.

Example:

function wpestate_get_video_header_image($video_url) {
return '<div class="wpestate_video_header"><video autoplay loop muted><source src="' . esc_url($video_url) . '" type="video/mp4"></video></div>';
}
function wpestate_header_image($image) {
// ... existing code ...
elseif (isset($post->ID)) {
$header_type = get_post_meta($post->ID, 'header_type', true);
if ($header_type === 'video') {
$video_url = get_post_meta($post->ID, 'header_video_url', true);
echo wpestate_get_video_header_image($video_url);
} else {
$header_data = wpestate_get_header_data($post->ID);
echo wpestate_get_custom_header_image($image, $header_data, $paralax_header);
}
}
// ... rest of the function ...
}

This guide provides an overview of the wpestate_header_image function in WPResidence, its functionality, and how to customize it. By understanding these components, you can modify and extend the header image functionality to suit your specific needs.

Technical how to | Custom Code RequiredWpResidence 5.0

Related Articles

  • Technical – How to Change the Minimum Image Dimensions for Property Uploads in WPResidence
  • Introduction to WPResidence Header Customization
  • Understanding WPResidence Header Types: An Overview
  • Customizing the WPResidence Logo Display

WP Residence Documentation

  • 1. General
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 2. Installation
  • 3. Installation FAQ
  • 4. Advanced Search
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 5. Agent, Agency & Developers
  • 6. Property Page
  • 7. Properties List
  • 8. Property Taxonomies
  • WpResidence Elementor Studio
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • Theme Options
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • Translation
  • FAQ
  • Pages
  • Header
  • Footer
  • Google or Open Street Maps
  • Payment Options
  • Plugins
    • Included Plugins
    • Third Party Plugins – IDX Compatibility
    • Third Party Plugins – Multi Languages
    • Third party Plugins – Other
  • Technical
    • Technical how to | Custom Code Required
    • Technical: Child Theme

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API