I get data from the server to dynamically create a video gallery on the client. Those data contain metadata-related information such as contributor etc.
I have a standard snippet for dublin core data in my webpage like
<meta name="DC.Source" id="videdsource" />
<meta name="DC.Description" id="metadesv" />
<meta name="DC.Creator" id="videdcreator" />
<meta name="DC.Contributor" id="videdcontr" />
//and so on, for all the dublin core elements...
Each time the users picks another video,I want to dynamically change the metadata values using a code like
document.getElementById("videdcreator").content=arrayvid[i];
This is not working. Because If I load the web page and look at the source code, the dublin core elements that are standard have a value , like
<meta name="DC.Rights" content="Copyright 2014" />
but, the elements that I want to change dynamically, have no values, like
<meta name="DC.Contributor" id="videdcontr" />
How do I fix this?
What is the best practice to dynamically handle multimedia metadata on a webpage?
Thanks
I'm fairly new to JS and to stackoverflow as well. Don't know if this is going to help you, but have you tried the following?
Ex. 1
Have id's to your meta tags -- checked
<meta name="DC.Source" id="videdsource" />
<meta name="DC.Description" id="metadesv" />
<meta name="DC.Creator" id="videdcreator" />
The trigger
object.onclick=changeTags();
JS function
function changeTags(){
$("#videdsource").attr("content","yourlink");
$("#metadesv").attr("content","Coolest video");
$("#videdcreator").attr("content","Chuck Norris");
}
Does this help you in any way?
This is was my mistake, because first of all, metadata dont support id.
But they have a name. So, in pure JS, I can do getElementsByName and then setAttribute
So the code is
//html part
<meta name="DC.Creator"/>
<button id="change" type="button">change it</button>
//javascript part
document.getElementById('change').onclick=myfunc;
var ha="ha";
function myfunc()
{
document.getElementsByName("DC.Creator")[0].setAttribute("content",ha);
}
You can see your changes by doing "inspect element" on your browser
Credits go to the user named "geomagas" on this Greek forum
Use php and do something like
<meta name="DC.Creator" id="videdcreator" content="<?echo $arrayvid["vidcreator"][i];?>"/>
Related
How can I generate dynamic meta tags for facebook on server side? Depending upon the data fetched from database, I need to dynamically set the value of og:title, og:description etc.
Can I use HttpServletResponse.addHeaders() to do that? If yes then how to do that?
In JSF, you can just use EL in template text.
<meta property="og:title" content="#{bean.og.title}" />
<meta property="og:description" content="#{bean.og.description}" />
<meta property="og:url" content="#{bean.og.url}" />
...
Bean and model can be prepared and used the usual way here.
See also:
Using JSF EL in a plain HTML attribute
Okay, I can not figure this out for the life of me. I created a new site, and wanted to add the open graph meta tags like on my old site (which is working fine). When I added these to my new site and tested them in facebook debugger, it says that they are not present. I get this back when I test it:
Inferred Property The 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property The 'og:title' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property The 'og:description' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags.
Also, it is not finding the image even though it is there as well. Here is the code from my site as follows:
<meta property="fb:admins" content="100002683693547" />
<meta property="og:title" content="JDerry Art" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://www.jderry.com/2015" />
<meta property="og:image" content="http://www.jderry.com/2015/images/link.jpg" />
<meta property="og:description" content="Art and Illustration by J. Derry" />
<meta property="og:site_name" content="JDerry Art" />
my new site URL is: http://www.jderry.com/2015/
I have tried all suggestions for similar issues on here and other forums, as well as tried moving the order of the tags to no avail...
Any and all help will be greatly appreciated as this is starting to drive me nuts as there appears to be no definite answer and all suggested solutions yield the same problem. Thanks in advance.
P.S. My old site was xhtml and my new site is HTML5, not sure if that has any influence on this issue?
When you are using Open Graph Object Debugger . make sure you check the time last scraped and make sure its up to date with the changes on your website.
you can click on fetch new scrape information , to get the new data. and right now your open graph tags are working fine .
These are the raw tags that we found
Meta Tag <meta property="fb:admins" content="100002683693547" />
Meta Tag <meta property="og:title" content="JDerry Art" />
Meta Tag <meta property="og:type" content="website" />
Meta Tag <meta property="og:url" content="http://www.jderry.com/2015" />
Meta Tag <meta property="og:image" content="http://www.jderry.com/2015/images/link.jpg" />
Meta Tag <meta property="og:description" content="Art and Illustration by J. Derry" />
Meta Tag <meta property="og:site_name" content="JDerry Art" />
I was having the same problem, and what was causing it for me was that the content of og:url was just mywebsite.com, and not http://www.mywebsite.com.
The problem for me was that I had ipv6 enabled for my site and I didn't had a proper configuration in my web server settings.
HEY GUYS HERE'S MY ANSWER, i HOPE IT WORKS FOR YOU AS WELL: I try'ed every sugestion I can get my hands on, and what worked for me was this:
go to: https://developers.facebook.com/tools/debug/og/object/
Once you are there, paste the URL from the web page you wish to share in the box, and hit the button "retrieve information from the new extraction"
After you do this, it will appear some information, WHAT YOU ARE GOING TO NEED from this information, is the "og:update_time" element, on the right side of this element you will have a number, you are going to need to add this element along with this number to your meta information, someting like this:
meta property="og:updated_time" content="1496821331"
every number for every page is UNIQUE, but I find that if you put the same number in more than one web page it still works, but you may wanna put the specific number for each web page you are going to need (NOTE: in my experience,
you DONT need to have the image in the same directory as the meta is, actually, I use an image from google images and work out just fine!)
this is an example of the og:updated_time
I hope this can help you guys.
How I fixed this issue:
Turns out that the facebook scraper was timing out before it could get the content. You can check if this is happening to you with this tool. It will give a red error message if it is indeed timing out.
I'm making a wordpress site so I fixed this with the "Super Cache" plugin, which caches the content so that the facebook scraper can load it fast enough to not timeout. You still have to scrape multiple times (up to 4) with the sharing debugger for all the content to come through and work because the image loading is asynchronous.
I'm trying to customize image, page title, and description data for facebook share feature on my page. When I view the og meta tags in the source of my page, I see the correct info
<meta property="og:title" itemprop="name" content="You got an A!" />
<meta property="og:description" itemprop="description" content="Find out how much you know about the Hittites at MYQUIZPAGE" />
<meta property="og:image" itemprop="image" content="http://PAGE/MYPAGE/MYIMAGE.jpg" />
However, when I plug the url into the facebook debugger, I instead see details of the parent site.
I dont know why this is, as the correct info is sent in the header, NOT appended afterwards or anything like that.
Im using the following anchor for the share button(wihch I have used many times in the past without fail)
<a href="//www.facebook.com/sharer/sharer.php?u=MYURL" target="_blank">
One more detail- the content of the og tags on my page depends on values in the url query string.
Any ideas as to what is going on?
This is my code, it's from Facebook, it's quite simple:
<div class="fb-share-button" data-href="http://www.mysite.com/" data-type="button_count"></div>
But when I click on the share button, I found that I can't control the description content of the website. Some other sites did but I don't know how they did it.
Is it possible to change it?
Thanks
Facebook Has complete instruction and the available properties you can add on The Open Graph protocol site
The basic meta tags are
<meta property="og:title" content="{My Title}" />
<meta property="og:type" content="{Site Type}" />
<meta property="og:url" content="http://example.com" />
<meta property="og:image" content="http://example.com/images/og_image.jpg" />
And there's more options if you want to add them
no you can't. You control the content with og metatags. If you want to provide a different description, you need to post via app, with the share dialogue: https://www.facebook.com/dialogue/feed?app_id=APP_ID&link=YOUR_LINK&description=YOUR DESCRIPTION&picture=A_PICTURE_URL&name=SITE TITLE&caption=BEST THINGS EVER etc etc
I installed the official facebook wordpress plugin, it helps to automatically add the following lines of code to my page:
<meta property="http://ogp.me/ns#locale" content="en_US" />
<meta property="http://ogp.me/ns#site_name" content="XXX" />
<meta property="http://ogp.me/ns#type" content="article" />
<meta property="http://ogp.me/ns#title" content="Contact" />
<meta property="http://ogp.me/ns#url" content="http://XXX.com" />
<meta property="http://ogp.me/ns/fb#app_id" content="XXX" />
Now I want to add a LIKE BOX to my page,
http://developers.facebook.com/docs/reference/plugins/like-box/
When I choose 'XFBML' code, it showed:
"Add an XML namespace to the tag of your document. This is necessary for XFBML to work in earlier versions of Internet Explorer."
<html xmlns:fb="http://ogp.me/ns/fb#">
My question is that do I still need to add this one line of code considering I already got the "meta property" added above? If I add this, would it conflict with "meta property"??
Also which versions of IE need that line of code?
Thanks!!
<html xmlns:fb="http://ogp.me/ns/fb#">
My question is that do I still need to add this one line of code considering I already got the "meta property" added above?
You would still need that, because it has nothing to do with Open Graph meta elements (which just provide some info about the document for “outside” parties like Facebook’s scraper), but with how the browser treats “unknown” tags in your document (and <fb:like-box> is such an unknown tag, because it does not exist in HTML).
If I add this, would it conflict with "meta property"??
No, there is no potential for any sort of “conflict” here.
Also which versions of IE need that line of code?
I don’t know exactly, but I’d guess at least 6 & 7.
If for some reason (CMS, whatever) you can not add this to the HTML element – then you can just use the HTML5 version of the plugin code instead – that uses just a normal DIV element, and that is not “unknown” to any browser. (Your document’s doctype does not have to be the HTML5 one for this to work.)