My php pages have some images in them, that I want to copy one of them to the <meta property="og:image" content="" /> tag in the head section of the page.
Example of the image tag:
<img class="img-responsive" border="0" src="../../../Gallery/path/file.jpg" alt="some text" width="640" height="460">
Expected output (to be added to the section) that trims everything from the above line, and just takes the path of the image from it:
<meta property="og:image" content="../../../Gallery/path/file.jpg" />
I tried somethings in the line with getElementById and innerHTML but it's not working. Also something like: jQuery( "img.img-responsive" );, (but it takes the whole line). I think it needs something like .removeAttr() but I am not sure how implement all that together.
- Another thing, and I am not sure if it is doable: If the page has more classes with the same name but with different images, is it possible to specify in the jQuery or Javascript code which image to use? (for example adding
,1for the first image, or,2to copy only the second?