How can i get absolute path of product Image or featured image of any post/product page?
I tried to like this:
$product = wc_get_product( $postid);
$product->get_image('large'); //output like <img src="url of image" alt="xyz"/>
Then i tried to get src path from image tag (from above output) using php prag_match function. then split it by domain url and got remaining path and created absolute path.
$filename = getcwd().'/wp-content/uploads/2016/02/xyz.jpg';
It works for me but it seems complex and managed thing. Please let me know if there any easiest way?
__DIR__
contains the absolute path to the directory of the currently executing php script.