That’s a little hard to explain. Maybe you’ve just gotten unlucky, but I wonder what happens if you pick a really random YouTube video and post it in one of the test threads. It really shouldn’t be a problem if the preview is hidden.
Discourse is mostly fine with posting photos, but it can only detect certain URL formats.
Almost any URL that ends with .jpg or .png should be recognized as a photo, as long as the link goes to a real photo and not just a page with a photo on it. Imgur and X/Twitter links will also be recognized as photos and show inline. Google photos do not in my experience.
Right-click on the photo and hit “Copy image link” or equivalent and you’ll usually get a URL that works.
What will definitely not work (trick or not) is directly uploading the photo. I.e., pasting the image data into the post rather than the URL to the photo. Upload to Imgur or another photo sharing site first, and past the link to that.
That’s what I do, but it hasn’t worked for a long, long time. The last time I was able to successfully link to a picture seems to have been just shy of a year ago.
My trick is to copy a photo on a page then paste into the address bar of the web browser. That gives me a link. I then copy that link out of the address bar and paste it into a post.
It has never failed in my experience, with the following caveat…
It will only fail if the number has already been used.
Say you post a video and forget to close the preview pane. The preview loads and when you try to save your post, it gives an error because it says you can’t embed a video. So you close the preview pane, add a &1 and it saves successfully.
Some one later tries to post your video in another thread and get the error, they add a &1 and still get the error because you already used it.
That’s the only time I’ve seen that happen to me. Just move to another number.
This thread was recently mentioned in another topic where we discussed Discourse self-hosting.
Anyway, about this YouTube issue… could it possibly be related to our particular combination of the default Onebox settings (“Onebox” is the Discourse name for the link preview generator) with our “no image uploads allowed” policy (which is pretty rare among Discourse forums, and possibly a contributing factor to this issue)?
If a mod happens to see this post (and this hasn’t already been tried), what if we disabled YouTube previews altogether so that copying and pasting URLs will always work, albeit without the previews? At least it wouldn’t require manual URL editing every time…
Probably. But it’s still a Discourse bug. Preview images should not count as media uploads. But I anticipate that this bug has fallen under the radar at Discourse because it’s rare to disable image uploads as we have.
I think it’s been speculated that this is exactly the problem.
I would be strongly opposed to this, because the various workarounds to posting YouTube videos as described in this thread are very easy to do, and inline YouTube videos are very useful and convenient. My own preferred workaround doesn’t usually require any URL editing – it’s to position the mouse cursor over the “Reply” button, paste the YouTube URL, and then immediately click the “Reply” button, before Discourse has a chance to create the preview and deny the posting.
My understanding is that sometime back over a year ago, Ed had agreed to escalate the problem with Discourse technical support. I would have to assume that the response was that there was no practical solution for our particular rather unique configuration.
I rather suspect that a fix wouldn’t be that hard, but that Discourse developers aren’t fond of putting in special-case exceptions which tend to make for aesthetically ugly code that becomes harder to maintain.
Editing the URL is a nice trick if that YouTube URL has been posted before, but otherwise it’s not necessary. You just have to be very quick between pasting the URL and clicking “Reply”, as I noted in post #34. It’s basically a two-handed or two-pawed operation that requires the “Reply” button to be hit immediately after the URL is posted, with no more than a fraction of a second delay. Once the URL is processed in the “Preview” window, posting will no longer work.