In recent years companies, including hospitals, have found a powerful tool in social media. But some have also experienced the legal consequences when something goes wrong. Naval Hospital Jacksonville in Florida, where viral images of newborn babies being mishandled by staff recently originated, may be the latest example.

Such inappropriate conduct, hastened by the prolific use of smartphones and ease of data sharing, can expose hospitals to a number of legal causes of action, experts say. But the risks can be mitigated, they added, by planning ahead and training employees.

Last week, a photo—shared 185,000 times on Facebook—showed a hospital staff member raising a middle finger to a baby. “How I currently feel about these mini Satans,” read the photo's caption. In an online video, another staff member is seen moving a baby to make it look like the child is dancing to rap music.