diff --git a/README.md b/README.md
index 91e2e9d..a3e78f1 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,17 @@ You can check here in use: https://www.miragenews.com/ghost-flight-pilots-fall-a
```
+## Sharing Images
+
+You can share an image a few ways:
+
+- Share an image at a URL, using `data-share-image-url` to specify the URL
+- Share a DOM element, either a `canvas` or an `img`, using `data-share-image-id` to specify the DOM element ID
+
+The image name will either be the filename of the image from the URL, or the DOM element id. To override this, use `data-share-image-name`.
+
+When sharing a remote image, all browser restrictions apply for fetching (e.g. CORS).
+
## Options
### data-share-title
@@ -91,6 +102,19 @@ The URL to be shared.
``data-share-url="https://nasa.gov"``
+### data-share-image-url
+The URL of the image to be shared.
+
+``data-share-image-url="https://www.nasa.gov/sites/all/themes/custom/nasatwo/images/nasa-logo.svg"``
+
+### data-share-image-id
+The DOM element ID of the image to be shared. Both `canvas` (the canvas itself, as a PNG) and `img` (the image reference in the `src`) are supported.
+
+``data-share-image-id="myCanvas"``
+
+### data-share-image-name
+The name to use for the shared image. If sharing a `canvas` the extension `.png` will be appended if it doesn't exist.
+
## Screenshots
### 1. buttons
diff --git a/demo.html b/demo.html
index 3686368..f940814 100755
--- a/demo.html
+++ b/demo.html
@@ -24,6 +24,15 @@
Title, text and URL defined
This share button will share a defined title, text and url set by data attributes.
+
Title, URL, and image URL defined
+
This share button will share a defined title and url set by data attributes and include an image from the given image URL.
+
+
+
Title, URL, and image ID (to an IMG tag) defined
+
This share button will share a defined title and url set by data attributes and include an image from the referenced DOM element.
+
+
+
diff --git a/img/nasa-logo.svg b/img/nasa-logo.svg
new file mode 100644
index 0000000..f69ca39
--- /dev/null
+++ b/img/nasa-logo.svg
@@ -0,0 +1,66 @@
+
+
+
+
\ No newline at end of file
diff --git a/js/better-share.js b/js/better-share.js
index bcbff15..13eab0d 100644
--- a/js/better-share.js
+++ b/js/better-share.js
@@ -1,171 +1,213 @@
function betterShare() {
- var that = this;
- this.btnSelector = '.better-share';
- this.closeBtnSelector = '.close-btn';
- this.modalID = 'better-share-modal';
- if (!$(this.btnSelector).length) return;
- this.buttons = [{
- facebook: ''
- }, {
- twitter: ''
- }, {
- email: ''
- }, {
- whatsapp: ''
- }, {
- telegram: ''
- }];
-
- this.buttonsHtml = '';
- this.getTitle = function() {
- if (this.button.data('share-title')) {
- return this.button.data('share-title');
- }
- if ($('head meta[property="og:title"]').length) {
- return $('head meta[property="og:title"]').first().attr('content');
- }
- return document.title;
- };
-
- this.getUrl = function() {
- if (this.button.data('share-url')) {
- return this.button.data('share-url');
- }
- if ($('head meta[property="og:url"]').length) {
- return $('head meta[property="og:url"]').first().attr('content');
- }
- return window.location.href;
- };
-
- this.getText = function() {
- if (this.button.data('share-description')) {
- return this.button.data('share-description');
- }
- if ($('head meta[property="og:description"]').length) {
- return $('head meta[property="og:description"]').first().attr('content');
- }
- };
-
- this.modalWidth = function() {
- return Math.min($(window).width() - 16, 550);
- }
-
-
- this.shareModal = function(close) {
- //create share modal html
- //social media icons
- var overlayID = this.modalID + '-overlay';
- $('#' + this.modalID).remove();
- $('body').removeClass(this.modalID + '-open');
- $('#' + overlayID).remove();
-
- if (typeof close == 'undefined') {
- if (!that.buttonsHtml) {
- $.each(this.buttons, function(index, data) {
- for (key in data) {
- if (data.hasOwnProperty(key)) {
- var value = data[key];
- that.buttonsHtml += '';
- }
- }
- });
-
- }
-
- var div = '