Problem with the IMDb Plugin

  • 2
  • Problem
  • Updated 2 years ago
  • Solved
  • (Edited)
Hi

So I'm trying to get the plugin to work on my site but I am experiencing a problem. 
On the plugin site it says The plugin will display the IMDb rating for all titles that have a rating, but if I have several movies with the same IMDb id on the same page only the first occurrence of that movie will show the rating.
How can I have several instances of the same movie all displaying their rating?
Here is a simple example of what I mean:
https://jsfiddle.net/70h1q4s3/3

Thanks.
Photo of JK

JK

  • 5 Posts
  • 6 Reply Likes

Posted 2 years ago

  • 2
Photo of Jeorj Euler

Jeorj Euler

  • 7459 Posts
  • 9878 Reply Likes
For the time being, a plugin user can solve this problem (at the potential expense of variability of styling), by appending the following HTML "script" tag block containing rudimentary JavaScript code to the HTML source markup of a web page hosted by the plugin user:
<script id="imdb-rating-api-tail-rudimentary">
(
function()
{
setTimeout(rescan,100,50);
function rescan(d)
{
var s,e=document.getElementsByClassName("imdbRatingPlugin"),
i,a,o={};
if
(
!(
(s=document.getElementById("imdb-rating-api"))&&
(e=document.getElementsByClassName("imdbRatingPlugin"))&&
e[0].getElementsByClassName("rating").length>0
)
)
{
if(d>0)setTimeout(rescan,100,d-1);
return
}
for(i=0;i<e.length;i++)
{
a=e[i].getAttribute("data-title");
if(!o[a])
o[a]=e[i];
else
if(e[i].getElementsByClassName("rating").length==0)
e[i].parentNode.replaceChild(o[a].cloneNode(true),e[i])
}
}
}
)
()
</script>
Photo of JK

JK

  • 5 Posts
  • 6 Reply Likes
Omg omg omg, this is AWESOME! Thank you!
Photo of Jeorj Euler

Jeorj Euler

  • 7459 Posts
  • 9878 Reply Likes
Hi, JK. You're welcome. It's a "quickfix". I intend to revisit this and upgrade it to account for plugs that repeat a title reference but use a different display style in doing so.
(Edited)
Photo of JK

JK

  • 5 Posts
  • 6 Reply Likes
Hello again. How will I know when an update is available and where will I find it?
Photo of Jeorj Euler

Jeorj Euler

  • 7459 Posts
  • 9878 Reply Likes
I would post it in this thread, and depending upon people's notification settings, they would see it in their e-mail inboxes. That covers the aforementioned "quickfix" and any followups thereto. I'm not sure what will happen if IMDb techs improve the actual plugin, though.

This conversation is no longer open for comments or replies.