• Resolved Vova Feldman

    (@svovaf)


    Hey @michaelwilliamson,

    First of all, thanks a lot for the plugin! We’ve been looking for a while how to streamline the process of importing content from Google Docs to WordPress, and your plugin is the closest to what we’ve been looking for.

    One of the key things that are missing in that puzzle is how to streamline file-naming of the uploaded images. It seems like Google Docs doesn’t preserve the original name of the uploaded file. Hence, the workaround that I found is adding a meta text before the image that looks like:
    [image filename="<name>" alt="<alt>"]

    I managed to “hack” mammoth-editor.js to automatically fetch the image metadata and wanted to offer a PR so others can enjoy it as well.

    What would be the best way to submit a PR? Do you have a GitHub repo?

Viewing 5 replies - 1 through 5 (of 5 total)
  • +1 for this! This would literally make the plugin perfect.

    Plugin Author Michael Williamson

    (@michaelwilliamson)

    Mammoth uses the alt text for the image as the basis for the filename (if the alt text is set). If Google Docs preserves the alt text for images when exporting to docx, then perhaps that would be sufficient?

    Thread Starter Vova Feldman

    (@svovaf)

    Thanks a lot for the tip, @michaelwilliamson! I did some experimenting and it works.

    1. To set the alt in a Google Doc, right click on the image and click the Alt text... option.
    2. Then, set the value in the Description field (not the Title): https://drive.google.com/file/d/1lJXFHQJHmgGA90grMQj_QftCGBPn2xP-/view

    The export from Google Doc to Word preserves the alts from the Description, and indeed, the plugin will pick them up, set them as the alt attribute, as well as nicely set the filename according to the alt.

    Michael:
    Few more things that I “hacked” which you may consider adding as a setting to the plugin (or maybe there’s one that I missed):

    1. The JS adds anchors like <a id="post-5-_sqejmlky1of5"></a> next to the titles. Is it possible to disable that?
    2. Images are added with a class attribute like class="wp-image-51", can it be disabled? We like to keep our source as clean as possible.
    3. Finally, one of the things that I’ve done is to dynamically add a target="_blank" attribute to all links that point to an external domain. That’s quite a popular approach and would be great if it could be added as an option.

    Looking forward!

    Plugin Author Michael Williamson

    (@michaelwilliamson)

    The anchors are from bookmarks in the document. If you want to get rid of the anchors, I’d suggest getting rid of the bookmarks in the original document.

    The image is added with that class for compatability with the WordPress editor. Without it, WordPress can’t properly identify the image.

    The target for hyperlinks is read from the original document. If the link is set to open in a new tab/window in the original document, that should be preserved during the conversion.

    Thread Starter Vova Feldman

    (@svovaf)

    @michaelwilliamson seems like Google Doc generates hidden bookmarks which are exported to the word doc. I did find a way to remove them with a VBA script, but it’s not straightforward at all.

    Up to you of course, but I’m thinking that offering the mentioned features in the plugin settings can make it more accessible for non-technical marketers.

    Thanks for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Pull Request for image filenames and alt attribute’ is closed to new replies.