You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
#jQuery Cache Images plugin
2
2
3
-
Plugin for jQuery that allows for the easy caching of image files in the browsers localstorage. The local storage approach allows the media to persist across sessions, while the browser manages all of the cross-domain privacy protections.
3
+
Plugin for jQuery that allows for the easy caching of image files in the browsers localStorage. The local storage approach allows the media to persist across sessions, while the browser manages all of the cross-domain privacy protections.
4
4
5
5
## Using the Plugin
6
6
The plugin can be used two ways. It can either be applied to a specific element in the DOM, or you can apply it to a container that will have images within it. Both approached will bind the Cache Image plugin to all future changes that occur to those elements or their children.
@@ -18,7 +18,7 @@ Each of these is optional.
18
18
`$('img#AnElement').cacheImages();`
19
19
Any selector here works, however it will bind to only existing elements. If you need to have the caching work on future dynamically created elements use the second approach.
20
20
21
-
### Attached to a Parent Container *Coming Soon*
21
+
### *Attached to a Parent Container **Coming Soon***
22
22
`$('div#AwesomeContainer').cacheImages();`
23
23
This will watch for changes to the parent and all child elements for changes that involve images. The plugin will step in, cache the image into local storage, and reveil the image to the user.
24
24
@@ -29,10 +29,16 @@ Allows you to easily drop caching into your dom additions. It will look at the c
Attempts to cache that image into your clients browser local storage. This can be very helpful if you have an app where you are storying data into webSQL or IndexedDB and want to grab images during an initial sync, but those images might not be needed until later. By caching the images earily you ensure that they would be available along with the other data.
32
+
Attempts to cache that image into your clients browser local storage. This can be very helpful if you have an app where you are storying data into webSQL or IndexedDB and want to grab images during an initial sync, but those images might not be needed until later. By caching the images early you ensure that they would be available along with the other data.
33
33
34
34
These images would later be automatically placed due to element or parent binding, or you could manually place them (see below).
If you need to use an image in your inline css, or in another context where you just need the encoded string you should use this function. It will return the encoded string if it has already been cached, or it will return the default (if that is already encoded), or null. This will not fetch the URL since that is an asynchronous event that cannot return your output.
40
+
41
+
36
42
# Credits and Thanks
37
43
* Based Heavily off of @doomhz plugin [jQueryImageCache](https://github.com/doomhz/jQuery-Image-Cache)
38
44
* Utilizing base64 encoding from @mathias[Encoding XHR image data](http://jsperf.com/encoding-xhr-image-data/33)
0 commit comments