1

I need to add dimensions/text data to the featured image on the right. I was going to add it to another image and swap it ... or maybe hide captions with data on the images and show them on the featured? Any thoughts on a best approach for this? Thanks so much for helping me!

http://test.pillarsoflifebook.com/ottomans/

Currently it's just one line of dimensions but I'd like this to be scalable incase the client wants other pages to have a description or more in depth text than a single line.

Thanks so much! Here's the JQuery I'm using for the swap currently:

function myFunction2() {
    var $large = jQuery('#largeImage1');

    //store the default image as the data src
    $large.data('src', $large.attr('src'));

    var src = jQuery('#largeImage').attr('src');
    jQuery('#thumbs1 img').hover(function () {
        $large.attr('src', jQuery(this).attr('src').replace('thumb', 'large'));
    }, function () {
        //on mouse leave put back the original value
        //$large.attr('src', $large.data('src'));
    });
}

jQuery(document).ready(function () {
    jQuery(myFunction2);
});
user40823
  • 111
  • 1
  • 2
  • 10
  • So you want Product name with the Image? – Pratik Joshi Mar 12 '14 at 05:30
  • what text ,you want to display at the right side of image? from where the Text will be taken? – Pratik Joshi Mar 12 '14 at 05:31
  • I need to display the product name AND dimensions. I'm not sure whether to add the text as the ALT ... add a caption ... or maybe just add the text to another image that shows on the right. What do you recommend? For example the first image would have the image name and below it 15x15x30 for example. – user40823 Mar 12 '14 at 05:33

2 Answers2

1

First use this code for bottommost 4 images (Design options) and tell is it alerting properly the name of items ?

And hover on 4 bottommost images

function myFunction() {
    var $large = jQuery('#largeImage');

    //store the default image as the data src
    //$large.data('src', $large.attr('src'));

    var src = jQuery('#largeImage').attr('src');


    jQuery('#thumbs img').hover(function () {
        $large.attr('src', jQuery(this).attr('src').replace('thumb', 'large'));
        var altText =jQuery(this).attr("alt");

        //alert(jQuery(this).parent().text());
        var existsClass=$large.parent().children().hasClass("prodName");
        //alert(existsClass);
        if(existsClass)
            //$large.parent().children().remove(".prodName");
            $large.parent().find("div").remove(); 

$large.parent().append('<div class="prodName" style="margin-left:220px">'+jQuery(this).parent().text()+'<br/>'+altText+'</div>');

    }, function () {
        //on mouse leave put back the original value
        $large.attr('src', $large.data('src'));
    });
}

jQuery(document).ready(function () {
    jQuery(myFunction);
});

Check this NEW code

Pratik Joshi
  • 11,485
  • 7
  • 41
  • 73
  • I added this to my Jquery file but i keep getting a pop up saying the image alt name. Please check this out: http://test.pillarsoflifebook.com/ottomans/ I changed #largeimage to #largeimage2 and the same with thumbs so I can make it work on this page only for now. – user40823 Mar 12 '14 at 05:50
  • Sorry and yes it is reporting the correct image name. – user40823 Mar 12 '14 at 05:52
  • So you want The value in Popup to display it at the right side of image? – Pratik Joshi Mar 12 '14 at 05:54
  • Hi Pratik! Thanks for all the help so far! I'm now seeing the name but it's to the right of the image AND it's not scrolling down since the featured image currently is position absolute. Any way to change this class to be below the featured image? Also .. how should I go about adding the product description/dimensions below the product name? THanks again so much for the help and going out of your way for me! – user40823 Mar 12 '14 at 06:12
  • I'm sorry I meant position fixed! : ) – user40823 Mar 12 '14 at 06:17
  • You want to show Description of product,But it should be there in HTML.I can only see product Name in your page,If there is description inside HTML associated with image ,then only i can display it. – Pratik Joshi Mar 12 '14 at 06:18
  • Should I add the description into the ALT tag or somewhere else? I can add some false content for now and fill in the real data later. – user40823 Mar 12 '14 at 06:19
  • Check :in
    just remove style="margin-left:220px" ,and tell output
    – Pratik Joshi Mar 12 '14 at 06:20
  • I added a dummy description 15x15x39 in the alt tag after the first few images. First image example: alt="CrissCross Ottoman 15x15x39" Only CrissCross Ottoman is showing. Have you been able to look at the page? I was hoping it would show under the image as it scrolls down since it's position fixed. – user40823 Mar 12 '14 at 06:28
  • I took text from The text Which is above image , So image name ,is taken from TEXT above small image.So you want its dimentions as description also to get displayed? – Pratik Joshi Mar 12 '14 at 06:32
  • Oh I didn't realize that. I thought you took the text from the ALT tag . Yes I want the name of the product (which is working) and the description (in this case just the dimensions) to display below the product name. – user40823 Mar 12 '14 at 06:37
  • put " the dimensions " in alt tag of image. I didnt see alt tag containing DIMENTIONS in => http://test.pillarsoflifebook.com/ottomans/ – Pratik Joshi Mar 12 '14 at 06:39
  • It seems to be working now. I had to change the styling in this line: $large.parent().append('
    ' Now it flows beneath the image as I hover down. Any advice to get rid of the margin-left and make it center aligned? Otherwise I just need to update the descriptions with the correct dimensions and I think we're in business!
    – user40823 Mar 12 '14 at 06:51
  • please give proper link to Your site : Is this link you are working on? http://test.pillarsoflifebook.com/ottomans/ – Pratik Joshi Mar 12 '14 at 06:53
  • I think you are using other link ,your code is not here – Pratik Joshi Mar 12 '14 at 06:54
  • Yes I'm using http://test.pillarsoflifebook.com/ottomans/ I'm seeing the product name and ALT under the image right now. – user40823 Mar 12 '14 at 06:56
  • Ok i cleared cache,ok now .But its ok ,i dont understand what your problem is "floats beneath ....." ,?? – Pratik Joshi Mar 12 '14 at 07:00
  • i think image shows title and Desc. below it even i scroll it ,what is problem? – Pratik Joshi Mar 12 '14 at 07:01
  • Everthing seems good now! I was wondering if I can center the text beneath? I'm using Margin-Left but would rather have it centered. I'm also using Margin-Top to get it below the image but would rather have it closer if possible since some images are taller than others and it makes a big space sometimes. I think once I update all the ALT tags this should be working perfectly! – user40823 Mar 12 '14 at 07:03
  • 1
    See. modify style to =>
    and tell me what else you want
    – Pratik Joshi Mar 12 '14 at 07:04
  • I think we're good Pratik. I have 90% of what wanted here and don't want to waste your time with CSS ... I can play with that. THank you SO MUCH! Let me know if I can help you in any way. – user40823 Mar 12 '14 at 07:07
  • 1
    :) welcome ,and post Qestions ,so i can Solve it .my mail id nutandevjoshi@gmail.com ,if any problem,send me Stack overflow link,or The link of website you have problem. – Pratik Joshi Mar 12 '14 at 07:10
  • I'm trying to adjust the positioning of the product name / alt tag JQuery is placing below the image. – user40823 Mar 18 '14 at 02:35
  • Over CrissCross and Cambridge Ottomans the text is overlying the actual image. For other products the text is right below. I'd like the text to always generate below the image itself without worrying about the actual image size. Any advice? – user40823 Mar 18 '14 at 02:39
  • please post this as new Question,i will answer. – Pratik Joshi Mar 18 '14 at 03:48
1

There are a few points to consider: -

  • Multiple images and having two (or more images), one for each dimension. With multiple images, the obvious first drawback is that the page will take longer to load (at least until the images are cached). One option is to load the images that are required immediately, and then the other images in the background.

    Now, you could also just have a single image and allow the browsers to scale it for you. If you do this then you would want to make sure that you retain the aspect ratio. Secondly, you would want to test it across the browsers and operating systems as some are better at this than others.

    You could also load the image into a canvas and do some cropping and resizing yourself.

    A final twist, depending on which browser versions you want to support is that you can use Scalable Vector Graphics (SVG) in HTML 5. I won't go into the details, but SVG is specifically very good at scaling to different sizes. See the MDN source here.

    There is a lot of information on resizing on the web, as a sample, see here, here and here.

  • Text embedded in the image. Well, unless there is something particularly fancy that you want to do with the text that can't be done by the browser, I would not suggest this. Every time you want to generate a new text blurb, you will need to generate a new image. Every time the customer says - 'could we just move the text a little to the left' you will need to create a new image. Not to mention the impact on SEO.

  • Storing the text. You can put the text in the alt tag, so long as it adheres to the intention of the alt tag. If the text is descriptive of the image, then it can go in the alt tag. If it goes beyond describing the image and is supporting text, then put it in a separate caption or span.

  • Display / style. This comes down to what you customer prefers and what looks best and blends best with your site while following standard usability guidelines. Normally this involves trial and error, sitting down with your customer and deciding what they like. Do they like the text above the image, over it or under it. Do they like it to show immediately, fade in, slide in, bounce, rotate, cycle through the colours of the rainbow and explode?

Community
  • 1
  • 1
acarlon
  • 16,764
  • 7
  • 75
  • 94
  • Thanks ACarlon. I'm not a fan of embedding the text in the image because I need to load an extra set of images (or hide a portion of the same image in the thumbnails) and also the text does nothing for SEO in an image. I think storing the text is the best option but formatting it might be an issue then. How would I go about listing the Product name, followed by dimensions, followed by a description for example? This might be an issue. – user40823 Mar 12 '14 at 06:09