How not to let image appear in the drag?

Asked

Viewed 586 times

-1

You know when you put an image on a website, and when you click on it and you hold it, it’s tiny and you drag it?

How to do not let the user drag or save image? Instagram for example you can’t save the image or drag it.

  • If images do not have a slideshow, use this css: img{ pointer-events: none; }

1 answer

0


This is a suggestion based on my knowledge. There are probably other ways to do.

1 - put the image as background and NOT with tag <img>. Thus:

<style>

.img {
    background-image: url('imagem/minhaImagem.jpg');
    width: 300px;
    height: 300px;
}

</style>

<div class="img">

</div>

This way he won’t be able to drag the image, or copy it. However, he will be able to figure out her path.

2 - Block access of image directory with .htaccess. You create a file with that name .htaccess inside the directory you want to block access to. In case images. In this file, you enter the following code:

<Directory /imagens> // <-- é necessário colocar o nome do diretório
    Options -Indexes 
</Directory>

And all your images will be inaccessible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.