Some great debugging here! Very useful suggestions.
@justtryit87 or @dinamiko – can you please advise where the below code should go?
$siteURL = get_site_url()."/";
$imgurl = get_the_post_thumbnail_url();
$imgurlonly = str_replace($siteURL,"",$courseImg);