0

I have a table with some list items coded like this:

<li data-thumbnail-path="content/media/thumbnails/1.jpg"
    data-url="content/media/images/1.jpg"
    data-thumbnail-overlay-color="#aa4080">
    <div>
        <p class="gallery1DecHeader">First description</p>
    </div>
</li>

My purpose is to use the ColorFinder JavaScript inside the data-thumbnail-overlay-color="";. This JavaScript needs 2 unique id, image (the original image) and color (the prominent color found) as shown in this example. Since I need to use it to change my overlay color, how could I insert the color id into my data-thumbnail-overlay-color=""; attribute? Is there a different way to do this?

NineCattoRules
  • 2,253
  • 6
  • 39
  • 84
  • So basically you want to insert a string inside the "data-thumbnail-overlay-color", right? – briosheje Mar 09 '15 at 10:57
  • @briosheje I'm here because I don't know what's the right way since I'm a novice coder...but to use it I need to set that id "color" into my attribute, just to use the color finder JavaScript – NineCattoRules Mar 09 '15 at 11:00
  • 1
    I'm not getting the question, that's the problem. What's the output you're expecting? I'm looking at this ColorFinder, and apparently needs just the image ID. So what you basically want to do is give to it the image, retrieve it's "RGB" and parse that RGB inside the data-thumbnail-overlay-color? – briosheje Mar 09 '15 at 11:03
  • @briosheje from the page of the Script "This snippet assumes you have an image element in your page whose id is image. It also assumes there is an element whose id is color and sets its background to the dominant color of the image." – NineCattoRules Mar 09 '15 at 11:09
  • @briosheje I can set the id `image` to my list item, but I need to set the id `color` to my attribute `data-thumbnail-overlay-color="";` – NineCattoRules Mar 09 '15 at 11:13
  • 1
    Of course it does, so? In your
  • I see some parameters, but I'm not sure you can use that function if the image is NOT in the DOM. Perhaps you can try by passing that as an Image object, but from what I'm seeing in github (https://github.com/pieroxy/color-finder/blob/master/src/colorfinder-1.1.js) the script is PRETENDING to receive a DOM image element, which may not be exactly the same as a generic image object. Is the image of the **data-url** printed somewhere inside your document?
  • – briosheje Mar 09 '15 at 11:15
  • After a rapid test, the script also accept a generic image object. I'm going to try to provide an answer, despite your question is absolutely unclear. – briosheje Mar 09 '15 at 11:20
  • @briosheje I wish to find the most prominent color of my thumbnail image. The path of the image is set like this: `data-thumbnail-path` and I wish to have the most prominent color found by the Script inside the `data-thumbnail-overlay-color` attribute. – NineCattoRules Mar 09 '15 at 11:27
  • data-thumbnail-path is not a valid parameter, it should be data-thumbnailPath or something like that. – briosheje Mar 09 '15 at 11:29
  • @briosheje the `data-thumbnail-path` is an attribute of another JavaScript I used – NineCattoRules Mar 09 '15 at 11:36
  • You seem to mix two different notions, *id* and *parameter*: - The term *id* applies to HTML elements with the `id` attribute set (they must be unique for a given page); - When you talk about a JavaScript program that accepts variable input values, then you should talk of these values as *parameters* of the program. It would make your question clearer with the correct terms. – Grégoire C Mar 09 '15 at 11:38
  • @geceo My first question was with "parameter" than another user edited to "attribute"...I searched and found here the answer: [link](http://stackoverflow.com/questions/6743365/difference-between-parameters-and-attributes). – NineCattoRules Mar 09 '15 at 11:43