nilsnolde / wordpress-markdown-git

:loop: WordPress plugin to add file content (Markdown, Jupyter notebooks) from a Git based VCS to a WordPress post; replaces https://github.com/gis-ops/md-github-wordpress
GNU General Public License v3.0
48 stars 14 forks source link

Images from private repos are not accessible on frontend #13

Closed LuigiBella closed 4 years ago

LuigiBella commented 4 years ago

Versions Wordpress: 5.4.1 Documents for Git: Markdown Git Version 0.1 (version released on March 8th)

Describe the bug With a BitBucket MD file that uses the complete path to an image stored on BitBucket, the output on the frontend shows a URL beginning with camo.githubusercontent.com and the image is not displayed.

0

URL where this issue can be seen: https://dahelpguide.luigibella.com/markdown-git/

Paste the shortcode and the censored contents of config.json

[git-bitbucket-markdown user=luigibella token=5XQ8pvTDW7fJtWHqz86u url="https://bitbucket.org/pacificdisastercenter/disasteraware-master-user-guide/src/master/1.2%20test%20page.md"]

config.json file is not present in this plugin version

To Reproduce Steps to reproduce the behavior:

  1. Install Markdown Git Version 0.1 Pushed to Github on March 8th
  2. Inset shortcode to BitBucket MD file with image links containing the full path to the image
  3. View on frontend

Screenshots 0

nilsnolde commented 4 years ago

Puuh, this was rather not so intuitive!

Everything is alright actually, the camo.blbla is just Github stuff added. The data-canonical-src tag tells you the original image. Basically the problem here is that you reference an image which needs authentication. Log out of Bitbucket and see if you can access the URL https://bitbucket.org/pacificdisastercenter/disasteraware-master-user-guide/raw/25d3aec045385c54b84ad90c88648cc9f75f3bba/images/1.2_figure_1.png. I can't let the plugin authenticate the URL for the image AFAIK.

Think I found a way to work around this in a series of experiments:

Don't take the image URL from the file itself, take it from the markdown on Bitbucket with right-click on the image itself and Save image address. It should look smth like https://bytebucket.org/nilsnolde/test-wp-plugin/raw/75cae613d140954349185292bdd5acd29a1a4ebe/img/IMG_0138.jpg?token=6d1d5454701e6426eb7dfb0009038358ae72f9f0. The important part being bytebucket.org and the token.

Now, I'm not sure how permanent that token is, but I'd figure it won't expire, since it's a static link. Of course Atlassian has a shit documentation for Bitbucket, which doesn't include that. And thanks to not being open source no way of knowing.

If you use that link instead in your markdown source code it will work. Do let me know if it did pls.

If, against all expectations, that token indeed has an expiry date and will invalidate at some point, the most sustainable option would be to have a separate public image repository or use a proper delivery service.

nilsnolde commented 4 years ago

Just released 1.0.2: https://wordpress.org/plugins/documents-from-git/

I added a "Troubleshooting" section describing this as well.

Closing, but feel free to open if anything unclear remains.