Yes , valid or permissible. Because , first of all , Makkah Sharif (Ka'bah Sharif and Masjidul Haram) is a subject of great respect and honor for us , but leaving it behind or standing behind it - standing , sitting or standing , does not cause disrespect to Makkah Sharif or breach of manners ; In the same way, even if you take a picture with Makkah Sharif behind you , it will not be a cause of disgrace to Makkah Sharif . There is no excuse for disrespecting Makkah Sharif or violating etiquette. However, it should be noted that such a picture should not be a matter of worship or riya shown to our people.