Vendor cover picture

Hello everyone,

I added an attribute, for vendor to upload a cover picture.
Now I’ve edited the file located at hivepress/includes/templates/class-vendor-view-page.php to create a new div around the user profile, to set the background image using my custom attribute.

                          'blocks'     => [
							'background_picture'=>[
								'type' => 'container',
								'attributes' => [
									'style' => "background-image:url()",
								],

Now how can I get the url in here, and is there another and better way to do what I want to do?

This is how it should look like:

Thank you for waiting. Please try this PHP code snippet to start, but it can require further advanced customization.

If you want to get the value of the vendor attribute, then please change get_attribute_field_name to get_ + your attribute field name.

Please do not make any changes in the core files of HivePress themes or plugins, as these changes will be removed on new updates. Please create a child theme or use the Code Snippets plugin to keep your custom changes.

add_filter(
	'hivepress/v1/templates/vendor_view_page/blocks',
	function($blocks, $template){
		$vendor = $template->get_context('vendor');
		
		if(!$vendor){
			return $blocks;
		}
		
		$attribute_value = $vendor->get_attribute_field_name();
		
		if(!$attribute_value){
			return $blocks;
		}
		
		return hivepress()->template->merge_blocks(
			$blocks,
			[
				'vendor_summary' => [
					'blocks' => [
						'background_picture'=>[
							'type' => 'container',
							'attributes' => [
								'style' => "background-image:url('".$attribute_value."')",
							],
						]
					]
				]
			]
		);
	},
	1000,
	2
);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.