WordPress wp_is_mobile()
can be the function that you’re looking for.
// Use the build-in function if WP
if(wp_is_mobile()) // On mobile
{
the_post_thumbnail_url('featured-image-mobile');
}
else
{
the_post_thumbnail_url('featured-image');
}