Skip to content

Instantly share code, notes, and snippets.

View ddebarros316's full-sized avatar

ddebarros316 ddebarros316

  • Toronto, Ontario
View GitHub Profile
@PunchRockgroin
PunchRockgroin / replace_vc_gitem_post_image_background.php
Created December 15, 2017 19:51
Replace Visual Composer / WPBakery Page Builder default image when no featured image present
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;
}