Picture loading method and device, and storage medium

By determining and utilizing the local image cache library in the network layer, the problem of image loading delay in WebView is solved, achieving more efficient image loading and an improved user experience.

WO2025201506A1PCT designated stage Publication Date: 2025-10-02BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/085650
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-03-29
Filing Date
2025-03-28
Publication Date
2025-10-02

AI Technical Summary

Technical Problem

When WebView loads images, it needs to make network requests, which causes image loading delays and reduces user experience.

Method used

In the network layer, determine whether the local image cache library stores the image to be loaded. If so, obtain it from the local cache library. Otherwise, request it from the server and cache it locally to avoid repeated downloads.

Benefits of technology

It improves the efficiency of image loading, reduces user waiting time, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025085650_02102025_PF_FP_ABST
    Figure CN2025085650_02102025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present disclosure are a picture loading method and device, and a storage medium. The picture loading method comprises: transmitting a picture loading request of a webview page container to a network layer; on the basis of the picture loading request, acquiring from the network layer a picture identifier of a first target picture, and on the basis of the picture identifier of the first target picture, determining whether the first target picture is stored in a local picture cache library; if the first target picture is stored in the local picture cache library, acquiring the first target picture from the local picture cache library, and returning same to the webview page container; and if the first target picture is not stored in the local picture cache library, acquiring the first target picture from a server end by means of a network library, and returning same to the webview page container. The embodiments of the present disclosure can improve the efficiency of picture loading and shorten the waiting time of a user, thereby improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Image loading method, device and storage medium

[0001] This application claims priority to Chinese Patent Application No. 202410383681.8 filed on March 29, 2024, and the contents of the above-mentioned Chinese patent application disclosure are hereby incorporated by reference in their entirety as a part of this application. Technical Field

[0002] The embodiments of the present disclosure relate to a method, device, and storage medium for loading an image. Background Art

[0003] The WebView (web view) page container is a component that embeds web content in mobile applications (such as mini-programs). It provides a container that can display web content. In mobile application development, WebView is often needed to display web content, including images.

[0004] However, when WebView loads images, it often needs to obtain image data through network requests, which may cause image loading delays and reduce user experience. Summary of the Invention

[0005] The embodiments of the present disclosure provide a method, device, and storage medium for loading an image, so as to improve the efficiency of loading an image, reduce the waiting time of a user, and improve the user experience.

[0006] In a first aspect, an embodiment of the present disclosure provides a method for loading an image, applied to a terminal device, the method comprising:

[0007] Transmit the image loading request of the web view page container to the network layer;

[0008] In the network layer, obtaining an image identifier of a first target image to be loaded according to the image loading request, and determining whether the first target image is stored in a local image cache according to the image identifier of the first target image;

[0009] If the first target image is stored in the local image cache, the first target image is obtained from the local image cache and returned to the web view page container for rendering; or

[0010] If the first target image is not stored in the local image cache, the image loading request is sent to the server, the first target image sent by the server is received, and the image is returned to the web view page container for rendering.

[0011] In a second aspect, an embodiment of the present disclosure provides an image loading device, including:

[0012] Image loading request acquisition unit The image loading request acquisition unit is used to transmit the image loading request of the web view page container to the network layer;

[0013] a determining unit configured to obtain, in the network layer, an image identifier of a first target image to be loaded according to the image loading request, and determine, based on the image identifier of the first target image, whether the first target image is stored in a local image cache;

[0014] The image acquisition unit is used to obtain the first target image from the local image cache library if the first target image is stored in the local image cache library, and return it to the web view page container for rendering; or, if the first target image is not stored in the local image cache library, send the image loading request to the server, receive the first target image sent by the server, and return it to the web view page container for rendering.

[0015] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: at least one processor and a memory;

[0016] The memory stores computer-executable instructions;

[0017] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the image loading method described in the first aspect and various possible designs of the first aspect.

[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the image loading method described in the first aspect and various possible designs of the first aspect is implemented.

[0019] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, comprising computer-executable instructions. When a processor executes the computer-executable instructions, the image loading method described in the first aspect and various possible designs of the first aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, a brief introduction will be given below to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0021] FIG1 is a diagram illustrating an example scenario of a method for loading an image according to an embodiment of the present disclosure;

[0022] FIG2 is a flow chart of a method for loading an image according to an embodiment of the present disclosure;

[0023] FIG3 is a flow chart of a method for loading an image according to another embodiment of the present disclosure;

[0024] FIG4 is a structural block diagram of a picture loading device provided by an embodiment of the present disclosure; and

[0025] FIG5 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0026] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present disclosure without making any creative efforts shall fall within the scope of protection of the present disclosure.

[0027] A WebView is a component that embeds web content in mobile applications (such as mini-programs). It provides a container for displaying web content. In mobile application development, WebView is often used to display web content, including images. However, when loading images, WebView often needs to obtain image data through network requests, which may cause image loading delays and reduce the user experience.

[0028] In order to solve the above technical problems, the present disclosure provides a picture loading method, which transmits a picture loading request of a web view page container to a network layer; in the network layer, the picture identifier of the first target picture to be loaded is obtained according to the picture loading request, and whether the first target picture is stored in the local picture cache library is determined according to the picture identifier of the first target picture; if the first target picture is stored in the local picture cache library, the first target picture is obtained from the local picture cache library and returned to the web view page container for rendering; or if the first target picture is not stored in the local picture cache library, the picture loading request is sent to the server, the first target picture sent by the server is received, and returned to the web view page container for rendering. In the embodiment of the present disclosure, by caching the pictures historically loaded by the Webview page container and the native page container into the local picture cache library, when the Webview page container needs to load the same picture, the picture in the local picture cache library is directly used without downloading the picture from the server, thereby improving the picture loading efficiency, reducing the user waiting time, and improving the user experience.

[0029] The scenario of the image loading method provided by the present disclosure is shown in Figure 1. In the terminal device, the image loading request of the Webview page container can be blocked, that is, the Webview page container is prevented from sending the image loading request directly to the server, and the image loading request is transmitted to the network layer; in the network layer, the image identifier of the first target image to be loaded is obtained according to the image loading request, and it is determined whether the first target image is stored in the local image cache library according to the image identifier of the first target image, wherein the local image cache library is used to store the images historically loaded by the Webview page container and the native page container; if the first target image is stored in the local image cache library, the first target image is obtained from the local image cache library and returned to the Webview page container for rendering; or, if the first target image is not stored in the local image cache library, an image loading request is sent to the server through the network library, and the first target image sent by the server is received and returned to the Webview page container for rendering, and the first target image is cached in the local image cache library.

[0030] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0031] The image loading method disclosed herein will be described in detail below with reference to specific embodiments.

[0032] Refer to Figure 2, which is a flow chart of a method for loading an image provided by an embodiment of the present disclosure. The method of this embodiment can be applied in a terminal device, and the method for loading an image includes:

[0033] S201: Transmitting an image loading request of a web view page container to a network layer.

[0034] In this embodiment, the Webview page container is the core view class in the WebKit framework. It is a component that embeds web page content in mobile applications (such as mini-programs, etc.). It provides a container that can display web page content. When a first target image needs to be displayed in the Webview page container, an image loading request is usually triggered, where the image loading request is usually a network request of the http protocol or the https protocol. In this embodiment, the image loading request of the Webview page container can be blocked, that is, the image loading request is not sent directly to the server through the Webview page container, but the image loading request is transmitted to the native network layer of the terminal device system, and the network layer performs the following steps. Optionally, the image loading request of the Webview page container can be blocked by the network proxy layer.

[0035] S202: In the network layer, obtain the image identifier of the first target image to be loaded according to the image loading request, and determine whether the first target image is stored in the local image cache according to the image identifier of the first target image.

[0036] In this embodiment, in the network layer, the images loaded by the Webview page container and the native page container can be stored in the local image cache library, and the cached images can be associated with the corresponding image identifiers in the local image cache library, where the image identifier can be a unique image identifier of the image. Specifically, the image identifier can be the path information of the image on the server (such as the path on the content distribution network CDN), for example, which can be obtained from the image loading request. Of course, the image identifier can also be other identifiers. The local image cache library can realize the caching of images loaded by the Webview page container and the native page container, and can also support the sharing and intercommunication of loaded images between the Webview page container and the native page container, that is, the Webview page container can obtain the images loaded by the native page container from the local image cache library, and the native page container can also obtain the images loaded by the Webview page container from the local image cache library.

[0037] Furthermore, after the network layer receives the image loading request of the Webview page container, it can obtain the image identifier of the first target image to be loaded according to the image loading request, and then search the first target image from the local image cache library according to the image identifier of the first target image to determine whether the first target image is stored in the local image cache library. If the first target image is stored in the local image cache library, it means that the first target image has been loaded before, and the first target image can be directly obtained from the local image cache library, that is, the following S203 is executed without requesting the first target image from the server again, so as to improve the loading efficiency of the first target image and reduce the user waiting time; if the first target image is not stored in the local image cache library, it means that the first target image has not been loaded before, and the first target image can be requested from the server, that is, the following S204 is executed.

[0038] Optionally, when obtaining the image identifier of the first target image to be loaded according to the image loading request, the URL (Uniform Resource Locator) corresponding to the first target image can be obtained from the image loading request, and the path information of the first target image can be obtained from the URL. Specifically, the query (request) part in the URL can be removed to obtain the path information of the first target image. Further, the image identifier of the first target image can be determined based on the path information of the first target image. Optionally, the path information can be used directly as the image identifier, or the path information can be processed to a certain extent and the processing result can be used as the image identifier. For example, the processing result can be processed using an information digest algorithm (such as MD5, etc.) and the processing result can be used as the image identifier. It should be noted that the method for obtaining the image identifier of the first target image here needs to be consistent with the method for obtaining the image identifier of the image in the local image cache.

[0039] S203: If the first target image is stored in the local image cache, obtain the first target image from the local image cache and return it to the web view page container for rendering.

[0040] In this embodiment, if the first target image is found from the local image cache library according to the image identifier of the first target image, there is no need to obtain the first target image from the server. Instead, the first target image is directly read from the local image cache library and returned to the Webview page container to be rendered and displayed in the Webview page container.

[0041] S204: If the first target image is not stored in the local image cache, send the image loading request to the server, receive the first target image sent by the server, and return it to the web view page container for rendering.

[0042] In this embodiment, if the first target image is not found in the local image cache library according to the image identifier of the first target image, it is necessary to obtain the first target image from the server. Optionally, in this embodiment, the network layer obtains the first target image from the server through the network library, wherein the network library is used for the terminal device to establish a connection with the server, and send the image loading request to the server, and receive the first target image returned by the server, and return the first target image to the Webview page container for rendering and displaying in the Webview page container. In addition, the first target image needs to be cached in the local image cache library for subsequent direct use by the Webview page container or the native page container.

[0043] The image loading method provided in this embodiment transmits the image loading request of the web view page container to the network layer; in the network layer, the image identifier of the first target image to be loaded is obtained according to the image loading request, and whether the first target image is stored in the local image cache library is determined according to the image identifier of the first target image; if the first target image is stored in the local image cache library, the first target image is obtained from the local image cache library and returned to the web view page container for rendering; or if the first target image is not stored in the local image cache library, the image loading request is sent to the server, the first target image sent by the server is received, and the image is returned to the web view page container for rendering. In this embodiment, by caching the images historically loaded by the Webview page container and the native page container into the local image cache library, when the Webview page container needs to load the same image, the image in the local image cache library is directly used without downloading the image from the server, thereby improving the image loading efficiency, reducing the user waiting time, and improving the user experience.

[0044] Based on any of the above embodiments, as shown in FIG3 , the method further includes:

[0045] S301, receiving a switching instruction to switch any second target image in the web view page container to a native page container for display;

[0046] S302: Determine, in the network layer, a picture identifier of the second target picture according to the switching instruction;

[0047] S303: Obtain the second target image from the local image cache according to the image identifier of the second target image, and return it to the native page container for rendering.

[0048] In this embodiment, when an image is displayed in the Webview page container, any second target image in the Webview page container can be switched from the Webview page container to the native page container for display. Specifically, the user can trigger a switching instruction to switch any second target image in the Webview page container to the native page container for display. Furthermore, the image identifier of the second target image can be determined in the network layer according to the switching instruction, and then the second target image can be obtained from the local image cache library according to the image identifier of the second target image, and the second target image can be returned to the native page container for rendering and display without having to obtain the second target image from the server again. Since the second target image is an image loaded in the Webview page container, the second target image must exist in the local image cache library. Therefore, directly reading the second target image from the local image cache library can improve the loading efficiency of the native page container for the second target image.

[0049] Among them, the switching instruction for switching any second target image in the Webview page container to the native page container for display can specifically be a full-screen viewing instruction for any second target image in the Webview page container, that is, when the user needs to view any second target image in the Webview page container in full screen (specifically, it can be triggered by clicking on the second target image or other operations), the Webview page container switches to the native page container, and the second target image is displayed in full screen in the native page container.

[0050] Of course, in the application scenario where the native page container is switched to the Webview page container, the image ID can also be obtained, and the corresponding image can be obtained from the local image cache library according to the image ID to improve the image loading efficiency.

[0051] Based on any of the above embodiments, transmitting the image loading request of the web view page container to the network layer in S201 may specifically include:

[0052] For the Webview page container in the target system, it is determined through the target interface in the Webview page container that the Webview page container does not respond to the image loading request, and the image loading request is transmitted to the network layer.

[0053] In this embodiment, for the Webview page container (WKWebView) in the target system (such as iOS system, etc.), it is determined through the target interface in the Webview page container that the Webview page container does not respond to the image loading request, and the image loading request is transmitted to the network layer, wherein the target interface in the Webview page container is pre-configured to not respond to the image loading request. Specifically, the target interface is a URL protocol processing interface, wherein the URL protocol processing interface is used to determine whether the URL protocol type of any network request can be responded to by the Webview page container, and the URL protocol processing interface is pre-configured so that the protocol type corresponding to the image loading request cannot be responded to by the Webview page container; specifically, the protocol type corresponding to the image loading request is the http / https protocol type, and the Webview page container usually only has the image loading request of the http / https protocol type, so the URL protocol processing interface can be pre-configured so that the http / https protocol type cannot be responded to by the Webview page container. More specifically, the URL protocol processing interface will output different Boolean values ​​(bool) for different network requests, where the Boolean value is True, indicating that the network request can be responded to by the Webview page container, and the Boolean value is False, indicating that the network request cannot be responded to by the Webview page container. In this embodiment, the Boolean value corresponding to the network request of the http / https protocol type in the pre-configured URL protocol processing interface is False.

[0054] During the specific implementation, the image loading request is input into the URL protocol processing interface, and the URL protocol processing interface outputs the judgment result that the image loading request cannot be responded to by the Webview page container according to the protocol type corresponding to the image loading request, that is, the output Boolean value is False, so that the Webview page container cannot respond to the image loading request.

[0055] For the Webview page container in any system other than the target system (iOS) (such as Android system, etc.), it is possible to pre-configure who will send any network request, which may include the Webview page container itself sending it to the server, or the network library sending it to the server. Therefore, the image loading request can be configured to be sent by the network library. Furthermore, when the image loading request of the Webview page container is blocked, the Webview page container can stop responding to the image loading request according to the preset configuration information, and transmit the image loading request to the network layer, wherein the preset configuration information is configured with an instruction that the image loading request is sent by the network library, thereby achieving the blocking of the image loading request of the Webview page container in any system other than iOS.

[0056] Based on any of the above embodiments, since the storage space of the local image cache library is limited, the images stored in the local image cache library can also be cleared, such as regularly clearing or clearing according to user instructions. The images can be cleared according to the order of image download time, loading frequency and other conditions, which will not be elaborated here.

[0057] Corresponding to the image loading method described in the preceding embodiment, FIG4 is a block diagram of the image loading device provided in the present embodiment. For ease of illustration, only the portions relevant to the present embodiment are shown. Referring to FIG4 , the image loading device 400 includes an image loading request acquisition unit 401, a determination unit 402, and an image acquisition unit 403.

[0058] The image loading request acquiring unit 401 is used to transmit the image loading request of the web view page container to the network layer;

[0059] The determining unit 402 is configured to obtain, in the network layer, an image identifier of a first target image to be loaded according to the image loading request, and determine, based on the image identifier of the first target image, whether the first target image is stored in a local image cache;

[0060] The image acquisition unit 403 is used to obtain the first target image from the local image cache library if the first target image is stored in the local image cache library, and return it to the web view page container for rendering; or, if the first target image is not stored in the local image cache library, send the image loading request to the server, receive the first target image sent by the server, and return it to the web view page container for rendering.

[0061] In one or more embodiments of the present disclosure, the local image cache library is used to store images historically loaded by the web view page container and the native page container.

[0062] In one or more embodiments of the present disclosure, when the image acquisition unit 403 sends the image loading request to the server, it is configured to:

[0063] The image loading request is sent to the server through the network library.

[0064] In one or more embodiments of the present disclosure, after receiving the first target image sent by the server, the image acquisition unit 403 is further configured to:

[0065] Cache the first target image in the local image cache library.

[0066] In one or more embodiments of the present disclosure, the image loading request obtaining unit 401 is further configured to receive a switching instruction for switching any second target image in the web view page container to a native page container for display;

[0067] The determining unit 402 is further configured to determine, in the network layer, a picture identifier of the second target picture according to the switching instruction;

[0068] The image acquisition unit 403 is further configured to acquire the second target image from the local image cache according to the image identifier of the second target image, and return the second target image to the native page container for rendering.

[0069] In one or more embodiments of the present disclosure, upon receiving a switching instruction to switch any second target image in the web view page container to a native page container for display, the image loading request obtaining unit 401 is configured to:

[0070] A full-screen viewing instruction for any second target image in the webpage view page container is received, where the full-screen viewing instruction is used to instruct the second target image to be switched to a native page container for display.

[0071] In one or more embodiments of the present disclosure, when obtaining the image identifier of the first target image to be loaded according to the image loading request, the determining unit 402 is configured to:

[0072] Obtaining a uniform resource locator corresponding to the first target image from the image loading request, and obtaining path information of the first target image from the uniform resource locator;

[0073] The picture identifier of the first target picture is determined according to the path information of the first target picture.

[0074] In one or more embodiments of the present disclosure, when transmitting the image loading request of the web view page container to the network layer, the image loading request obtaining unit 401 is configured to:

[0075] For the web view page container in the target system, it is determined through the target interface in the web view page container that the web view page container does not respond to the image loading request, and the image loading request is transmitted to the network layer.

[0076] In one or more embodiments of the present disclosure, when transmitting the image loading request of the web view page container to the network layer, the image loading request obtaining unit 401 is configured to:

[0077] For a web view page container in any system other than the target system, the web view page container stops responding to the image loading request according to preset configuration information and transmits the image loading request to the network layer, wherein the preset configuration information is configured with instructions for the image loading request to be sent by the network library.

[0078] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail in this embodiment.

[0079] Referring to FIG5 , there is shown a schematic diagram of the structure of an electronic device 500 suitable for implementing an embodiment of the present disclosure. The electronic device 500 may be a terminal device or a server. The terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), and fixed terminals such as digital TVs and desktop computers. The electronic device shown in FIG5 is merely an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.

[0080] As shown in FIG5 , the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. Various programs and data required for the operation of the electronic device 500 are also stored in the RAM 503. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0081] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although FIG5 shows an electronic device 500 having various devices, it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.

[0082] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0083] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0084] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0085] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.

[0086] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet Service Provider).

[0087] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0088] The units involved in the embodiments described in this disclosure may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."

[0089] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0090] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0091] In a first aspect, according to one or more embodiments of the present disclosure, a method for loading an image is provided, comprising:

[0092] Transmit the image loading request of the web view page container to the network layer;

[0093] In the network layer, obtaining an image identifier of a first target image to be loaded according to the image loading request, and determining whether the first target image is stored in a local image cache according to the image identifier of the first target image;

[0094] If the first target image is stored in the local image cache, the first target image is obtained from the local image cache and returned to the web view page container for rendering; or

[0095] If the first target image is not stored in the local image cache, the image loading request is sent to the server, the first target image sent by the server is received, and the image is returned to the web view page container for rendering.

[0096] According to one or more embodiments of the present disclosure, the local image cache library is used to store images historically loaded by the web view page container and the native page container.

[0097] According to one or more embodiments of the present disclosure, sending the image loading request to the server includes:

[0098] The image loading request is sent to the server through the network library.

[0099] According to one or more embodiments of the present disclosure, after receiving the first target image sent by the server, the method further includes:

[0100] Cache the first target image in the local image cache library.

[0101] According to one or more embodiments of the present disclosure, the method further includes:

[0102] receiving a switching instruction for switching any second target image in the web view page container to a native page container for display;

[0103] In the network layer, determining a picture identifier of the second target picture according to the switching instruction;

[0104] The second target image is obtained from the local image cache according to the image identifier of the second target image, and is returned to the native page container for rendering.

[0105] According to one or more embodiments of the present disclosure, receiving a switching instruction for switching any second target image in the web view page container to a native page container for display includes:

[0106] A full-screen viewing instruction for any second target image in the webpage view page container is received, where the full-screen viewing instruction is used to instruct the second target image to be switched to a native page container for display.

[0107] According to one or more embodiments of the present disclosure, obtaining the image identifier of the first target image to be loaded according to the image loading request includes:

[0108] Obtaining a uniform resource locator corresponding to the first target image from the image loading request, and obtaining path information of the first target image from the uniform resource locator;

[0109] The picture identifier of the first target picture is determined according to the path information of the first target picture.

[0110] According to one or more embodiments of the present disclosure, blocking the image loading request of the Webview page container and transmitting the image loading request to the network layer includes:

[0111] For a web view page container in a target system, determining, through a target interface in the web view page container, that the web view page container does not respond to the image loading request, and transmitting the image loading request to the network layer. According to one or more embodiments of the present disclosure, transmitting the image loading request of the web view page container to the network layer includes:

[0112] For the Webview page container in any system other than the target system, the Webview page container stops responding to the image loading request according to the preset configuration information and transmits the image loading request to the network layer, wherein the preset configuration information is configured with instructions for the image loading request to be sent by the network library.

[0113] In a second aspect, according to one or more embodiments of the present disclosure, a picture loading device is provided, including:

[0114] An image loading request acquiring unit, configured to transmit the image loading request of the web view page container to the network layer;

[0115] a determining unit configured to obtain, in the network layer, an image identifier of a first target image to be loaded according to the image loading request, and determine, based on the image identifier of the first target image, whether the first target image is stored in a local image cache;

[0116] The image acquisition unit is used to obtain the first target image from the local image cache library if the first target image is stored in the local image cache library, and return it to the web view page container for rendering; or, if the first target image is not stored in the local image cache library, send the image loading request to the server, receive the first target image sent by the server, and return it to the web view page container for rendering.

[0117] According to one or more embodiments of the present disclosure, the local image cache library is used to store images historically loaded by the web view page container and the native page container.

[0118] According to one or more embodiments of the present disclosure, when the image acquisition unit sends the image loading request to the server, it is configured to:

[0119] The image loading request is sent to the server through the network library.

[0120] According to one or more embodiments of the present disclosure, after receiving the first target image sent by the server, the image acquisition unit is further configured to:

[0121] Cache the first target image in the local image cache library.

[0122] According to one or more embodiments of the present disclosure, the image loading request acquiring unit is further configured to receive a switching instruction for switching any second target image in the web view page container to a native page container for display;

[0123] The determining unit is further configured to, in the network layer, determine a picture identifier of the second target picture according to the switching instruction;

[0124] The image acquisition unit is further configured to acquire the second target image from the local image cache according to the image identifier of the second target image, and return the second target image to the native page container for rendering.

[0125] According to one or more embodiments of the present disclosure, when receiving a switching instruction to switch any second target image in the web view page container to a native page container for display, the image loading request acquisition unit is configured to:

[0126] A full-screen viewing instruction for any second target image in the webpage view page container is received, where the full-screen viewing instruction is used to instruct the second target image to be switched to a native page container for display.

[0127] According to one or more embodiments of the present disclosure, when the determination unit obtains the image identifier of the first target image to be loaded according to the image loading request, it is configured to:

[0128] Obtaining a uniform resource locator corresponding to the first target image from the image loading request, and obtaining path information of the first target image from the uniform resource locator;

[0129] The picture identifier of the first target picture is determined according to the path information of the first target picture.

[0130] According to one or more embodiments of the present disclosure, when transmitting the image loading request of the web view page container to the network layer, the image loading request obtaining unit is configured to:

[0131] For the web view page container in the target system, it is determined through the target interface in the web view page container that the web view page container does not respond to the image loading request, and the image loading request is transmitted to the network layer.

[0132] According to one or more embodiments of the present disclosure, the image loading request acquisition unit is configured to:

[0133] For a web view page container in any system other than the target system, the web view page container stops responding to the image loading request according to preset configuration information and transmits the image loading request to the network layer, wherein the preset configuration information is configured with instructions for the image loading request to be sent by the network library.

[0134] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: at least one processor and a memory;

[0135] The memory stores computer-executable instructions;

[0136] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the image loading method described in the first aspect and various possible designs of the first aspect.

[0137] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the image loading method described in the first aspect and various possible designs of the first aspect is implemented.

[0138] In a fifth aspect, according to one or more embodiments of the present disclosure, a computer program product is provided, comprising computer-executable instructions. When a processor executes the computer-executable instructions, the image loading method described in the first aspect and various possible designs of the first aspect is implemented.

[0139] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

[0140] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0141] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

Claims

1. A method for loading an image, applied to a terminal device, comprising: Transmit the image loading request of the web view page container to the network layer; In the network layer, obtaining an image identifier of a first target image to be loaded according to the image loading request, and determining whether the first target image is stored in a local image cache according to the image identifier of the first target image; If the first target image is stored in the local image cache, the first target image is obtained from the local image cache and returned to the web view page container for rendering; or If the first target image is not stored in the local image cache, the image loading request is sent to the server, the first target image sent by the server is received, and the image is returned to the web view page container for rendering.

2. The method according to claim 1, wherein The local image cache library is used to store images historically loaded by the web view page container and the native page container.

3. The method according to claim 1 or 2, wherein: The sending the image loading request to the server includes: The image loading request is sent to the server through the network library.

4. The method according to any one of claims 1 to 3, wherein: After receiving the first target image sent by the server, the method further includes: Cache the first target image in the local image cache library.

5. The method according to any one of claims 1 to 4, further comprising: receiving a switching instruction for switching any second target image in the web view page container to a native page container for display; In the network layer, determining a picture identifier of the second target picture according to the switching instruction; The second target image is obtained from the local image cache according to the image identifier of the second target image, and is returned to the native page container for rendering.

6. The method according to claim 5, wherein: The receiving of the switching instruction for switching any second target image in the web view page container to the native page container for display includes: A full-screen viewing instruction for any second target image in the webpage view page container is received, where the full-screen viewing instruction is used to instruct the second target image to be switched to a native page container for display.

7. The method according to any one of claims 1 to 6, wherein: The obtaining, according to the image loading request, an image identifier of a first target image to be loaded includes: Obtaining a uniform resource locator corresponding to the first target image from the image loading request, and obtaining path information of the first target image from the uniform resource locator; The picture identifier of the first target picture is determined according to the path information of the first target picture.

8. The method according to any one of claims 1 to 7, wherein: The step of transmitting the image loading request of the web view page container to the network layer includes: For the web view page container in the target system, it is determined through the target interface in the web view page container that the web view page container does not respond to the image loading request, and the image loading request is transmitted to the network layer.

9. The method according to any one of claims 1 to 7, wherein: The step of transmitting the image loading request of the web view page container to the network layer includes: For a web view page container in any system other than the target system, the web view page container stops responding to the image loading request according to preset configuration information and transmits the image loading request to the network layer, wherein the preset configuration information is configured with instructions for the image loading request to be sent by the network library.

10. A picture loading device, comprising: An image loading request acquiring unit is configured to transmit the image loading request of the web view page container to the network layer; a determining unit configured to, in the network layer, obtain an image identifier of a first target image to be loaded according to the image loading request, and determine, according to the image identifier of the first target image, whether the first target image is stored in a local image cache; The image acquisition unit is configured to, if the first target image is stored in the local image cache library, obtain the first target image from the local image cache library and return it to the web view page container for rendering; or, if the first target image is not stored in the local image cache library, send the image loading request to the server, receive the first target image sent by the server, and return it to the web view page container for rendering.

11. An electronic device comprising: at least one processor and memory, wherein The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the image loading method according to any one of claims 1 to 9.

12. A computer-readable storage medium storing computer-executable instructions, wherein: When the processor executes the computer-executable instruction, the image loading method according to any one of claims 1 to 9 is implemented.

13. A computer program product comprising computer-executable instructions, wherein: When the processor executes the computer-executable instruction, the image loading method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Cross-platform image caching implementation method based on webview of mobile terminal

    CN107291519A

  • Method and device for displaying webpage with embedded pictures

    CN107301182A

  • Page loading method and device, storage medium and electronic equipment

    CN116166911A

  • Network resource loading method and device, electronic equipment and storage medium

    CN116361588A

  • Method and device for accessing local file based on WebView and storage medium

    CN117194830A