Problem with the IMDb Plugin

  • 2
  • Problem
  • Updated 1 year 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 1 year ago

  • 2
Photo of Vincent Fournols

Vincent Fournols

  • 2901 Posts
  • 4892 Reply Likes
Hi JK,

By construction, you cannot have "several movies with the same IMDb id". Each ID is unique for only one object (movie, episode, video game, etc.). If the object gets deleted or merged into another one, the ID will not be reassigned.

Can you share a practical exemple of the issue you are facing?
Photo of Jeorj Euler

Jeorj Euler

  • 7289 Posts
  • 9526 Reply Likes
Hi, Vincent Fournols. For clarification, the topic pertains to the feature found at https://www.imdb.com/plugins.
Photo of JK

JK

  • 5 Posts
  • 6 Reply Likes
What I mean is several of the same movie, ie with the same id.
In my case I have collections of movies and often the same movie is in more than one collection.
Other cases could be if you have a layout with thumbnails and somewhere else on the page a bigger version of that. Or if you have a popup when you hover or click an object, if you want the rating to show both on the object and the popup that is not currently possible.
(Edited)
Photo of Vincent Fournols

Vincent Fournols

  • 2901 Posts
  • 4892 Reply Likes
JK,
I mean can you quote a precise exemple with an IMDb ID (tt99999999) and the related program titles which seem attached to it?
Or do I get something wrong?
(Edited)
Photo of JK

JK

  • 5 Posts
  • 6 Reply Likes
Not sure what you need. You have an example in the jsfiddle I linked to:
https://jsfiddle.net/70h1q4s3/6/
Photo of Jeorj Euler

Jeorj Euler

  • 7289 Posts
  • 9526 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

  • 7289 Posts
  • 9526 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

  • 7289 Posts
  • 9526 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.