You can first check if laptopReference exist or not, use data-sly-test to validate, if true then execute your logic.
<sly data-sly-test="${properties.laptopReference}"
data-sly-use.myImg="${properties.laptopReference}/jcr:content/metadata">
<!-- add your logic--------->
//if true then your logi...