Created
December 15, 2017 19:51
-
-
Save PunchRockgroin/083d2a9c76470a82470eddfb4fbeca56 to your computer and use it in GitHub Desktop.
Replace Visual Composer / WPBakery Page Builder default image when no featured image present
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function replace_vc_gitem_post_image_background($output){ | |
// Get the URL to replace in string background-image: url('https://yoursite.com/wp-content/plugins/js_composer/assets/vc/vc_gitem_image.png') !important; | |
$url = get_site_url(null, '/wp-content/plugins/js_composer/assets/vc/vc_gitem_image.png'); | |
// Full http(s) path to image | |
$new_url = 'full-uri-to-new-image.ext'; // 1024x1024 image | |
// String Replace | |
$new_output = str_replace($url, $new_url, $output); | |
// Return new string | |
return $new_output; | |
} | |
add_filter('vc_gitem_template_attribute_post_image_background_image_css_value', 'replace_vc_gitem_post_image_background', 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, thanks!