Picture uploading method, system, terminal and medium based on rich text editorTechnical Field
The invention belongs to the technical field of picture uploading, and particularly relates to a method, a system, a terminal and a medium for automatically uploading pictures based on a rich text editor.
Background
Currently, rich text editors are a text editing tool that must be used to release graphics and text information, and there are many mature products or some open source editors on the market. The format and style of the graphics and text information vary widely, and the sizes of the pictures can not be unified. When an information operator edits an article in a rich text editor of a third party and copies the article to a system of the information operator for publishing, the picture link may limit access by the third party or the picture link has dead time, so that the published article may not normally display the picture. But no report is found about the method for automatically uploading pictures based on a rich text editor in the prior art. Therefore, a method for automatically uploading pictures based on a rich text editor is needed.
Through the above analysis, the problems and defects of the prior art are as follows: the prior art has not reported about the method for automatically uploading pictures based on the rich text editor.
In the prior art, the uploading, beautifying and displaying effects of the pictures are poor, and the quality, size and position of the pictures are easy to change, so that the uniformity of the pictures is influenced.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a method, a system, a terminal and a medium for automatically uploading pictures based on a rich text editor.
The invention is realized in such a way that the picture automatic uploading system based on the rich text editor is composed of a front-end page, a server and a file server.
The front-end page is used for triggering a scanning event when a user pastes an article into the editor, and scanning all rich-text containers and article contents to scan a picture container and code scanning article contents; after the scanning is finished, uploading the picture array to a server side in a file stream form, a container identifier and an article portrait identifier;
and the server is used for carrying out modeling, calculation, picture processing and picture uploading operations according to the picture file stream, the container identifier and the article portrait identifier uploaded by the front end.
Another object of the present invention is to provide an automatic picture uploading method based on a rich text editor, which applies the automatic picture uploading system based on a rich text editor, and the automatic picture uploading method based on a rich text editor includes the following steps:
step one, a front-end page triggers a scanning event when a user pastes an article into an editor, and scans all rich text containers and article contents to scan a picture container and a code scanning article content;
secondly, uploading the picture array to a server side in a file stream form, a container identifier and an article portrait identifier after scanning;
and step three, the server side carries out modeling, calculation, picture processing and picture uploading operations according to the picture file stream, the container identifier and the article portrait identifier uploaded by the front end.
Further, in the first step, the scanning the picture container includes:
putting all the picture containers into an array, and adding a unique identifier to each container;
the code scanning article content comprises:
and analyzing and collecting the article portrait to generate an article portrait identifier.
Further, in the third step, the server side performs modeling, calculation, picture processing and picture uploading operations according to the picture file stream, the container identifier and the article portrait identifier uploaded by the front end, and the method includes:
(1) modeling according to the article portrait identifier uploaded at the front end;
(2) modeling according to the user portrait identifier stored in the database;
(3) modeling according to database resources;
(4) measuring by adopting correlation according to the matching degree of the user portrait, the article portrait and the resource model;
(5) selecting a resource with the highest matching degree, and inquiring to obtain a corresponding small pendant element;
(6) the server processes the file flow uploaded by the front end to generate a picture file, carries out layer merging and beautifying processing on the picture and the small pendant to obtain a new picture, and then uploads the new picture and the unique container identifier to a file server;
(7) after receiving the picture and the unique container identifier uploaded by the server, the file server generates a new picture link according to the unique image container identifier and an appointed format and returns the new picture link to the server;
(8) and the server returns the new picture link to the front-end page, the front-end page finds the corresponding container according to the unique identifier of the picture container after receiving the picture link returned by the server, and backfills the picture link into the picture container to finish picture display.
Further, in step (1), the vector identifiers of the article portrait are as follows:
A=(A1:W1,A2:W2,...,Am:Am);
wherein A ismRepresenting an article portrait identifying keyword, WmRepresenting the weight of the keyword, generally considering that the keyword placed in front has higher weight; the semantics of the article portrait identification keywords are generally related to the domain and classification to which the article belongs.
Further, in step (2), the vector identifier of the user portrait is as follows:
U=(U1:W1,U2:W2,...,Un:Wn);
wherein, UnRepresenting user portrait keywords, WnRepresenting the weight of the keyword, generally considering that the keyword placed in front has higher weight; the semantics of the user portrait keyword are generally related to the industry and the field where the user is located.
Further, in step (3), the vector representation of the resource model is as follows:
R=(R1:W1,R2:W2,...,Ry:Wy);
where y is the dimension for resource search, RyFor properties or resource items that can describe a resource, RyThe method comprises the following steps that data fields describing resources in a resource library are formed, and each field is composed of a plurality of words; wyIs the weight of the resource item, representing RyRepresenting the extent of resource R.
Further, in step (4), the correlation is calculated as follows:
suppose a user portrait model vector U is (U)1:W1,U2:W2,...,Un:Wn) The article portrait model vector A is (A)1:W1,A2:W2,...,Am:Am) The information resource model vector R of a certain resource is (R)1:W1,R2:W2,...,Ry:Wy);DkjIs UkAppears in RjFrequency of (1) · j ═ 1.·, m; dhjIs AkAppears in RjJ 1.. times, m, then the relevance g of the resource to the interest is expressed as:
and (3) inquiring and filtering the resource set by using the relevancy algorithm to obtain a relevant resource record set, namely a set of all resources with relevancy g >0, and meanwhile, sequencing the record set in a reverse order according to relevancy, wherein the record set is ranked in the front with high matching degree.
Another object of the present invention is to provide an information data processing terminal comprising a memory and a processor, the memory storing a computer program, the computer program when executed by the processor causing the processor to execute the rich text editor-based picture automatic uploading method.
Another object of the present invention is to provide a computer-readable storage medium storing instructions which, when executed on a computer, cause the computer to execute the method for automatically uploading a picture based on a rich text editor.
By combining all the technical schemes, the invention has the advantages and positive effects that: according to the method for automatically uploading the pictures based on the rich text editor, when the articles are copied to the rich text editor, the images of the articles are automatically analyzed and collected, the pictures and the images of the articles are uploaded to the server, the server beautifies the pictures according to the images of the users and the images of the articles, the pictures are uploaded to the file server after the beautification is completed, the pictures are stored in the file server, and then new pictures are returned to the front end for display. In the process, the user is almost non-sensory, the system can complete uploading, beautifying and displaying of the picture silently, and the quality, size and position of the picture cannot be changed.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments of the present invention will be briefly described below, and it is obvious that the drawings described below are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a method for automatically uploading a picture based on a rich text editor according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail with reference to the following embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In view of the problems in the prior art, the present invention provides a method, a system, a terminal and a medium for automatically uploading pictures based on a rich text editor, which are described in detail below with reference to the accompanying drawings.
The automatic picture uploading system based on the rich text editor provided by the embodiment of the invention comprises a front-end page, a server and a file server;
the front-end page is used for triggering a scanning event when a user pastes an article into the editor, and scanning all rich-text containers and article contents to scan a picture container and code scanning article contents; after the scanning is finished, uploading the picture array to a server side in a file stream form, a container identifier and an article portrait identifier;
and the server is used for carrying out modeling, calculation, picture processing and picture uploading operations according to the picture file stream, the container identifier and the article portrait identifier uploaded by the front end.
As shown in fig. 1, the method for automatically uploading a picture based on a rich text editor provided by the embodiment of the present invention includes the following steps:
s101, when a user pastes an article to an editor, a front-end page triggers a scanning event, and all rich-text containers and article contents are scanned to scan a picture container and code scanning article contents;
s102, uploading the picture array to a server in a file stream form, a container identifier and an article portrait identifier after scanning;
and S103, the server side carries out modeling, calculation, picture processing and picture uploading operations according to the picture file stream, the container identifier and the article portrait identifier uploaded by the front end.
The present invention will be further described with reference to the following examples.
The invention adopts an automatic picture uploading mechanism based on a rich text editor, which consists of a front-end page, a server and a file server.
The front end page triggers a scan event when the user pastes an article into the editor, scanning all rich text containers and article content to accomplish the following two things:
firstly, scanning a picture container: all picture containers are put into an array, and a unique identifier is added to each container.
Secondly, scanning the content of the article: and analyzing and collecting the article portrait to generate an article portrait identifier.
And after the scanning is finished, uploading the picture array to a server side in a file stream form, a container identifier and an article portrait identifier.
The server side needs to perform operations such as modeling, calculation, picture processing, picture uploading and the like according to the picture file stream, the container identifier and the article portrait identifier uploaded by the front end, and the operations mainly comprise the following steps:
modeling is carried out according to article portrait identification uploaded at a front end, and the vector identification of the article portrait is as follows:
A=(A1:W1,A2:W2,...,Am:Am);
wherein A ismRepresenting an article portrait identifying keyword, WmThe weight of a keyword is expressed, and the keyword placed in front is generally considered to have a higher weight. The semantics of the article portrait identification keywords are generally related to the domain and classification to which the article belongs.
Modeling according to the user portrait identifier stored in the database, wherein the vector identifier of the user portrait is as follows:
U=(U1:W1,U2:W2,...,Un:Wn);
wherein, UnRepresenting user portrait keywords, WnThe weight of a keyword is expressed, and the keyword placed in front is generally considered to have a higher weight. The semantics of the user portrait keyword are generally related to the industry and the field where the user is located.
Thirdly, modeling is carried out according to the database resources, and the vector representation of the resource model is as follows:
R=(R1:W1,R2:W2,...,Ry:Wy);
where y is the dimension used for resource search. RyFor properties or resource items that can describe a resource, RyIt is the individual data fields in the resource pool that describe the resource, each field being made up of a number of words. WyIs the weight of the resource item, representing RyRepresenting the extent of resource R.
Fourthly, measuring by adopting correlation according to the matching degree of the user portrait, the article portrait and the resource model, wherein the calculation method of the correlation is as follows:
suppose a user portrait model vector U is (U)1:W1,U2:W2,...,Un:Wn) The article portrait model vector A is (A)1:W1,A2:W2,...,Am:Am) The information resource model vector R of a certain resource is (R)1:W1,R2:W2,...,Ry:Wy)。DkjIs UkAppears in RjJ ═ 1.. times, m. DhjIs AkAppears in RjJ ═ 1.. times, m. The relevance g of the resource to the interest is expressed as:
and (3) inquiring and filtering the resource set by using the relevancy algorithm to obtain a relevant resource record set (a set of all resources with relevancy g > 0), and sequencing the record set in a reverse order according to relevancy, wherein the record set is ranked in the front with high matching degree.
And fifthly, selecting the resource with the highest matching degree, and inquiring to obtain the corresponding small pendant element.
And sixthly, the server processes the file flow uploaded by the front end to generate a picture file, layer combination and beautification are carried out on the picture and the small pendant to obtain a new picture, and then the new picture and the unique container identifier are uploaded to a file server.
And seventhly, after receiving the picture and the unique container identifier uploaded by the server, the file server generates a new picture link according to the unique image container identifier and an appointed format and returns the new picture link to the server.
And eighthly, the server returns the new picture link to the front-end page, after receiving the picture link returned by the server, the front-end page finds the corresponding container according to the unique identifier of the picture container, and backfills the picture link into the picture container to finish picture display.
In the whole process, the user is almost non-sensory, the system can complete the works of uploading, beautifying, displaying and the like of the picture silently, and the quality, the size and the position of the picture cannot be changed.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When used in whole or in part, can be implemented in a computer program product that includes one or more computer instructions. When loaded or executed on a computer, cause the flow or functions according to embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website site, computer, server, or data center to another website site, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL), or wireless (e.g., infrared, wireless, microwave, etc.)). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
The above description is only for the purpose of illustrating the present invention and the appended claims are not to be construed as limiting the scope of the invention, which is intended to cover all modifications, equivalents and improvements that are within the spirit and scope of the invention as defined by the appended claims.