aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-04-02 17:14:31 +0100
committerMichael Williamson <mike@zwobble.org>2016-04-02 17:14:31 +0100
commit6a4cc9231f219c0047272c56081f881eab800d74 (patch)
treea9631dfa47eb3db6a7060255e8b3042f3255756f /README.md
parent3afd698984f9ec3fcb9b16e5d6c12ea4a23dfb53 (diff)
Rename images.inline to images.imgElement
Diffstat (limited to 'README.md')
-rw-r--r--README.md24
1 files changed, 13 insertions, 11 deletions
diff --git a/README.md b/README.md
index 00fa1b2..98079c6 100644
--- a/README.md
+++ b/README.md
@@ -212,10 +212,10 @@ For instance, the following would replicate the default behaviour:
```javascript
var options = {
- convertImage: mammoth.images.inline(function(element) {
- return element.read("base64").then(function(imageBuffer) {
+ convertImage: mammoth.images.imgElement(function(image) {
+ return image.read("base64").then(function(imageBuffer) {
return {
- src: "data:" + element.contentType + ";base64," + imageBuffer
+ src: "data:" + image.contentType + ";base64," + imageBuffer
};
});
})
@@ -459,9 +459,9 @@ Each message has the following properties:
#### Image converters
-An inline image converter can be created by calling `mammoth.images.inline(func)`.
-This creates an inline `<img>` element for each image in the original docx.
-`func` should be a function that has one argument called `element`.
+An image converter can be created by calling `mammoth.images.imgElement(func)`.
+This creates an `<img>` element for each image in the original docx.
+`func` should be a function that has one argument `image`.
This argument is the image element being converted,
and has the following properties:
@@ -470,16 +470,18 @@ and has the following properties:
* `contentType`: the content type of the image, such as `image/png`.
-`func` should return an object (or a promise containing an object) with a `src` property,
-which will be used as the `src` attribute on the `<img>` element.
+`func` should return an object (or a promise of an object) of attributes for the `<img>` element.
+At a minimum, this should include the `src` attribute.
+If any alt text is found for the image,
+this will be automatically added to the element's attributes.
For instance, the following replicates the default image conversion:
```javascript
-mammoth.images.inline(function(element) {
- return element.read("base64").then(function(imageBuffer) {
+mammoth.images.imgElement(function(image) {
+ return image.read("base64").then(function(imageBuffer) {
return {
- src: "data:" + element.contentType + ";base64," + imageBuffer
+ src: "data:" + image.contentType + ";base64," + imageBuffer
};
});
})