I’ve also built in features for future proofing. API Username and Password (in case ImgFlip starts to monitor the usage) and the URL, even though ImgFlip supports HTTPS already.
Please report any issues via GitHub or here.
Enjoy!
Update:
2015-10-02 14:00 PM EDT
Fixed the fact that multiple memes could be selected. I still need to look into handling any errors returned from the API properly.
Okay recent changes in Discourse have removed string-buffer and the use of rawTemplate, so to support non-updated versions, there is a tag v0.5.0 that will let you keep operating.
My guess is that you got yourself blocked cause you are a fast typer. I did manage to post a post with an image there @cpradio you may want to default tl1 on your sandbox.
XMLHttpRequest cannot load https://api.imgflip.com/get_memes?username=removed&password=removed&_=removed.
Request header field Discourse-Visible is not allowed by Access-Control-Allow-Headers in preflight response.
That seems awfully specific to Discourse. Was there any changes around 'discourse/lib/ajax' that I should be aware of?
Ahh will that is new, I guess we broke you, you should not use the “discourse” ajax helpers here, they are designed for talking to Discourse. Instead just use jQuery direct.
Potential problem following a recent upgrade - Maybe Chrome related.
We’re seeing mixed content errors in the console and ImgFlip memes are not display correctly on Chrome with the latest Discourse and the latest version of the ImgFlip plugin.
Hi @cpradio, I can’t be certain when this started to fail as the community doesn’t use this plugin daily, but the first report coincided with me upgrading to a later version of 2.2.0.beta7 tonight.
We had previously been running an earlier version of 2.2.0beta7 but these errors surfaced after taking the +115 version. As I say, that might just be coincidental.
So far, it seems to only happen on Chrome - both mobile and desktop. Firefox and Safari both seem to work.
To reproduce
Simply post an image from imgflip.
In Chrome it will show a broken image icon in the post and the console will display errors like this…
The MESSAGE_BUS_FAIL errors only occurred after a polling delay - i.e. it looks like the page was made unstable before those errors occurred.
Some ‘odd’ stuff that might help you track it down
The meme is actually created and displays in the preview pane prior to posting. Only once the Reply button is pressed does it fail to display properly in the post list.
I get a notification from Chrome that ‘this page is trying to load scripts from unauthenticated sources’ that appears in the URL bar.
Even though the meme in the post shows as a broken image link, the post depth observes the size that the embedded image would have taken up and if you mouse click the ‘space’ where the image should be, the lightbox appears and actually displays the meme.
Oddly (to me anyway) If the meme was created in Firefox or Safari then everyone can see it, but if the meme was created in Chrome then nobody gets to see it.
Configuration details
The forum is hosted over https via Letsencrypt.
We’re running the latest version of your the plugin on Discourse v2.2.0.beta7 +115
I’ve reproduced it on Chrome version 71.0.3578.98 (Official Build) (64-bit) on Linux but it’s been reported as failing on Chrome mobile too.
I have confirmed that imgflip is returning the image URL as HTTP instead of HTTPS. It seems changing the URL from HTTP to HTTPS in the composer window will get it to load. Ideally imgflip will just return the HTTPS url, I’ll reach out and see if they will make the change.
I created a branch that forces the return image URL to use HTTPS, I’d rather imgflip resolve this themselves, but if they do not, then you can just point to this branch in your app.yml using
Potentially both. I do believe Chrome is much more sensitive, however, I don’t recall if imgflip initially returned HTTPS image urls or if it always returned HTTP. Sadly, all of my sandbox tests downloaded the files locally, so I can’t easily tell at the moment.
Okay, doing more research I found information indicating it has always been this way with ImgFlip. I’m going to merge the branch into the master branch. @bletch, this means you can remove the -b force-https from your app.yml sometime later today/tomorrow, which will require a rebuild.
Even if ImgFlip does fix this on their end, it shouldn’t impact the plugin negatively.
Hey good news! I heard back from them today, they made the change on their end and now return the payload as HTTPS. I’ve confirmed the plugin continues to work as expected.
I was previously running your force-http branch and whilst chasing down another but on the forum I thought I move to the master branch. This is misleading, I’ve reverted to the force-https branch and the issue is still there.
Our users are now reporting that they can’t insert memes. Looking at the browser console I see this error.
Access to XMLHttpRequest at 'https://api.imgflip.com/caption_image?username=imgflip_hubot&password=imgflip_hubot&template_id=87743020&text0=Work?&text1=Fail?' from origin 'https://sandbox.cpradio.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I don’t think that is it, the error is the fact imgFlip changed how you authenticate, you now must signup for an account and use your account credentials. Try that.
Previously they just had a dummy account that was available for everyone to use. https://api.imgflip.com/