0

I have a view in drupal 7 and I am displaying node title and node image . I need to give id for a image. Now I am getting:

<img typeof="foaf:Image" src="http://localhost/drupal-7.36/sites/default/files/styles/medium/public/field/image/STF-332.jpg?itok=Kpd_9XUk" width="220" height="220" alt="">

But I need Id .Means I need

<img typeof="foaf:Image" src="http://localhost/drupal-7.36/sites/default/files/styles/medium/public/field/image/STF-332.jpg?itok=Kpd_9XUk" width="220" height="220" alt="" id="myID">
0

If a unique class is acceptable, you can add a class to a field using built-in features. Under the field settings:

enter image description here

0

What do you need that ID for? If you need it for some java-script processing on the image you can add a span with the image id inside it next to the image with the style display:none. To do so add the NID field BEFORE the image in the fields and then check the Rewrite Results and use this code:

enter image description here

Now you can easily get the image ID by this JS code

var nid = $("TheImageSelector").siblings(".image-span").text();

But if you have to use the ID you need to use template files. install Image Link Formatter module to get the image link instead of the image object then build the <a> .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.