Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to detect if the linked page has a media file?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #37120

    Can javascript / jquery detect if a link to another page has a media file, specifically a video file on that page?

    For example:

    YWP (yahoo web player) has the capability to detect a media file on the current page and works just fine.

    But when I have a Blog title link or summary link that goes to the page with the media file, I would like to add a small media icon to the left of the blog title (if it has a media file in the blog detail page).

    Another person will be logging in to add the blog entries, so I’m not looking to have the end user do any extra work or add classes.

    I figure if there is a way to detect if the link the page is going to (blog detail) has an embedded video or linked video, I can just use jquery to add a class to that title and insert the media video image.

    or am I just dreaming over here.

    CK

    #98894
    karlpcrowley
    Participant

    Hey,
    Yahoo Web Player uses open graph to get the information about the video on the page
    This is the same with Facebook, IMDB, YouTube and a few others

    http://ogp.me/

    #98938

    but I’m trying to detect if the page link has a video on it (not the page I’m on – YWP already does that very nicely), so that I can display a media (video) icon next to the text link. I hope I’m asking my question correctly.

    CK

    #98940
    Senff
    Participant

    So basically, if you have a link on your page (page A) to another page (page B), then your link should show an icon if there is a video present on page B?

    That sounds a little complex and unnecessary to me, I would just check the page myself and add a class to the link. But that’s me. :)

    #98941
    karlpcrowley
    Participant

    I’ve done this once before but can’t remember exactly how

    The best thing to do it use JavaScript to post the URL to a script on your server which will use cURL to read in the page and parse the OG tags, then return the image if it exists or a generic one if it doesn’t

    This way you can display a nice loading gif while the server does the work and doing this with JavaScript would definitely cause the page to hang

    Also, on your server you could either store the images or links to the images to make it faster if the same site is entered again

    #99006

    thanks for the suggestions.
    the client would not have HTML access to the title to add a class.
    also, it’s a hosted CMS, so no access to server.

    YMP does have a class added to the script, so I’m using it now, but I have to include the video link in the blog summary in order to show the icon becuase it detects media on the current page.

    It’s not that big of a deal, I thought it would add value to the visitor if they new the entry had media in it before they clicked on it. – like webmd com does.

    thanks again for the responses.

    CK

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.