Forum
YouTube videos
Hi, I've installed the add-on to perch/addons/fieldtypes/youtube/youtube.class.php and curl is enabled. I have created the API key and added the following to post.html.
<perch:blog id="video" type="youtube" label="YouTube video URL" output="embed" width="800" order="4" />
I can add the YouTube to a post in admin but I can't see the video when the viewing post on the site. I've saved all content.
Any ideas? Thanks
What do you get on your site?
Can we also see your Diagnostics Report?
Hi Drew, everything else added to the post through the admin is displayed. Just no Youtube video.
Rachel, here's the diagnostics report...
If you remove
output="embed"
what do you get?The URL of the YouTube video is displayed.
Ok, great.
What does
output="player"
give you?Just the same Drew. Outputs the URL of the video.
Can you turn on debug, and then submit your content and let me know what it outputs? There should be an orange section with the YouTube API response.
Yes, here it is:
There's your answer - you'll need to check your API key.
I've checked the API key, generated a new one and updated the config file. Can't see anywhere on the Google API manager that has referrer restrictions? So there's nothing wrong with the post.html file?
No, the issue is way before that - Perch can't get the information back from the API due to the above error.
Okay, strange. I'm now getting the iframe code displayed on the post and not the URL as before so it must be getting something back from API?
Has the message in debug changed? That iframe can be deduced directly from your input.
It has yes. No longer returning an error but was still showing the iframe code on my post. Changed the post.html file to:
and it works!
Is there a way to detect if there is a video associated with the post in a similar way to the
<perch:if exists="image">
for images?<perch:if exists="video">
should work.Of course! Thanks for you help Drew.