Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3804018
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:27:12+00:00 2026-05-19T14:27:12+00:00

I am trying to pass along both the src and the rel tag values.

  • 0

I am trying to pass along both the src and the rel tag values. Here’s the sample input.

<img class="image" src="example.jpg" title="" rel="value" />

The following is some code that is parsing all <img> tags on a page.

add: function(src, rel) {
    if (this.cache[src]) {
        return this.cache[src];
    }
        if (this.cache[rel]) {
            return this.cache[rel];
        }
    var image = new Image();
    image.src = src;
        image.rel = rel;
    this.setStyle(image, {display: 'block'});
    if (image.complete && image.width) {
        return image;
    }
    image.onload = (function(scope) {
        return function() {
            scope.cache[src] = image;
        };
    })(this);
        jQuery(image).attr('rel', function() { image.rel } );
    return image;
},

However, this is my output.

<img src="example.jpg" style="display: block;" />

It’s as if it’s completely ignoring the rel tag. I need to pass the rel tag value from the old <img> to the new <img>.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:27:12+00:00Added an answer on May 19, 2026 at 2:27 pm

    The code is setting the properties. Not sure, but if the rel property doesn’t map to the attribute, it won’t show up.

    Also jQuery muddles the distinction between attributes and properties a bit, so I’m not sure how it treats rel.

    When you’re setting the rel, add a setAttribute() call.

    var image = new Image();
    image.src = src;
    image.rel = rel;
    image.setAttribute('rel',rel);
    

    Your original code does cause the rel property to be set, but not the attribute. This will actually set the attribute.

    You should be able to get rid of this line:

    jQuery(image).attr('rel', function() { return image.rel } );
    

    EDIT:

    Here’s an alternate solution:

    It seems that if you first set image.rel = rel;, the jQuery has no effect. Get rid of that line, and the jQuery code will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass multiple image files along with album id to insert.php,
I'm trying to encode an image using base64 in Node.JS to pass along to
I'm trying to use hidden fields in a form to pass along state selections
The table below works well. However, I am trying to pass $row[username] along as
I am trying pass class as value in hashmap. I need to get the
I am trying to take a PHP variable and pass it along to Flash
I'm trying to pass along the question AND the id of the question in
I am trying to use window.open() to pass along some arguments to another page.
MVC 3. VB.NET application.. I am trying to pass a id along to keep
I am trying to pass an array of values into an array of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.