jQuery plug-in ImgAreaSelect implements avatar upload preview and cropping functions

小云云
Release: 2018-01-10 13:11:10
Original
1541 people have browsed it

This article mainly introduces the jQuery plug-in ImgAreaSelect to implement the avatar upload preview and cropping function. Friends who need it can refer to it. I hope it can help everyone.

In the previous section of the essay, we already know the basic knowledge about the jQuery plug-in ImgAreaSelect; now let’s look at an example:

First of all, we need to know what functions we should implement?

(1) The image can be uploaded and previewed

(2) Drag and crop the image so that it can display the cropped area

(3) Display the area to be cropped The coordinates

Secondly, how to reference the plug-in?

Let’s take a closer look!

The first step: first introduce the style and file package (introduce according to your own location)

     
Copy after login

The second step: first use p layout style, as shown in the figure below

 

亲,请上传图片并裁剪

选区预览

坐标
X1:
Y1:
X2:
Y2:

Copy after login

css style:

Copy after login

Step 3: To achieve the upload preview effect of the image

Idea: Pass the src of the image through input to the first img, and then pass the src of the first img to the src of the second img

Copy after login

In this way, the following effects can be achieved:

Click to browse

Click to select:

Step 4: Implement the area selection function

Copy after login

This way you can achieve the following effects La~~~

At this step, you can realize the uploading and cropping functions of the avatar. Of course, it will be more perfect if you add the path to the database later~~~~

(---------------------------------------------- --------------------------There should be a dividing line here-------------- -------------------------------------------------- -----)

If you just want to implement a simple image cropping function, then you can take a look at the following code, no comments will be made here~~~

Of course, If you don’t understand the code above, you can also modify it by referring to the following one. Just add the image upload preview function~~~~

Rendering: (You can know by comparing the pictures, the following one It just lacks the browsing function, everything else is exactly the same)

          

Click and drag on the image to select an area.

Selection Preview

Coordinates
X1:
Y1:
X2:
Y2:

Copy after login

Related recommendations:

jQuery plug-in imgAreaSelect example explanation

Use the jQuery plug-in imgAreaSelect to obtain the image information of the selected domain

##imgareaselect + php to achieve image cropping

The above is the detailed content of jQuery plug-in ImgAreaSelect implements avatar upload preview and cropping functions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!