Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 24 of 24

Thread: Image Name Alt Text

  1. #1
    Amy P is offline Member
    Join Date
    Jun 2007
    Posts
    50

    Default Image Name Alt Text

    I was wondering if there is an easy way to change the image name alt text instead of it being named it's product id? I want it to be the same name as the product name.

    I can see in each variant where I can add the alt text however my variants do not display any images; only the parent.

    Can someone please help me?

    Thanks in advance.

  2. #2
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    There are SEAltText fields for BOTH the Product and the ProductVariant tables and these are handled in the Admin > Product or ProductVariant > Search Engine tabs. Seems like you probably want to change the ones in the Product table. But it might also depend on how your XML packages are setup to display the data.

    You could also run this SQL statement
    Code:
    UPDATE Product
    SET SEALtText = Name
    That would change every record to have the same alt text as the name.

    If you're going to do this, make sure you do it in a test environment first so that you can see how it changes your data before doing it on your live website.
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  3. #3
    Amy P is offline Member
    Join Date
    Jun 2007
    Posts
    50

    Default

    No I am looking at changing the Image alt text. The SEAlttext field is for the search engine.

    Does anyone know how to do this?

  4. #4
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    Here's a snippet from our main product XML package:

    Code:
    <xsl:param name="pSEAltText" select="aspdnsf:GetMLValue(SEAltText)"></xsl:param>
    <xsl:param name="AltText">
    	<xsl:choose>
    		<xsl:when test="$pSEAltText=''"><xsl:value-of select="$pName" /></xsl:when>
    		<xsl:otherwise><xsl:value-of select="$pSEAltText" /></xsl:otherwise>
    	</xsl:choose>
    </xsl:param>
    <xsl:param name="pLink" select="aspdnsf:ProductLink(ProductID, SEName, 0)" />
    <div itemscope="" itemtype="http://schema.org/Product">
    	<table border="0" cellpadding="0" cellspacing="0" width="100%">
    		<tr>
    			<td align="left" valign="top" width="220" rowspan="2">
    				<xsl:element name="a">
    					<xsl:attribute name="href">
    						<xsl:text>http://ourdomain/images/Product/large/</xsl:text>
    						<xsl:value-of select="ProductID"/>
    						<xsl:text>.jpg</xsl:text>
    					</xsl:attribute>
    					<xsl:attribute name="class">
    						<xsl:text>thickbox</xsl:text>
    					</xsl:attribute>
    					<xsl:attribute name="title">
    						<xsl:value-of select="Name"/>
    					</xsl:attribute>
    					<xsl:attribute name="rel">
    						<xsl:text>extra</xsl:text>
    					</xsl:attribute>
    					<xsl:attribute name="id">
    						<xsl:text>mainImageLink</xsl:text>
    					</xsl:attribute>
    
    					<img>
    						<xsl:attribute name="src">
    							<xsl:text>http://ourdomain/images/Product/medium/</xsl:text>
    							<xsl:value-of select="ProductID"/>
    							<xsl:text>.jpg</xsl:text>
    						</xsl:attribute>
    						<xsl:attribute name="itemprop">
    							<xsl:text>image</xsl:text>
    						</xsl:attribute>
    						<xsl:attribute name="alt">
    							<xsl:value-of select="Name"/>
    						</xsl:attribute>
    						<xsl:attribute name="title">
    							<xsl:value-of select="Name"/>
    						</xsl:attribute>
    						<xsl:attribute name="id">
    							<xsl:text>mainImage</xsl:text>
    						</xsl:attribute>
    						<xsl:attribute name="width">
    							<xsl:text>200</xsl:text>
    						</xsl:attribute>
    						<xsl:attribute name="height">
    							<xsl:text>200</xsl:text>
    						</xsl:attribute>
    					</img>
    You'll see at the top that it creates a variable called AltText which is either taken from the SEAltText field in the db or if there's nothing in it, the Name field from the db. You would expect to see that used down near the bottom of the code where it defines the Alt attribute for the product image. However, in our case, we have ignored this and chosen to use the product name instead.
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  5. #5
    Amy P is offline Member
    Join Date
    Jun 2007
    Posts
    50

    Default

    I guess either I am confused or it is just not working right for us. I have the SEAltText field completed on the majority of my products but no matter what it still just shows the ProductID number for the image name.

  6. #6
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Can you post your xmlpackage?



    TTFN

    BFG

  7. #7
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    You could try something like this in your product.xml package

    <xsl:attribute name="alt"><xsl:value-of select="$pName" disable-output-escaping="yes"/></xsl:attribute>

  8. #8
    dayhawk is offline Member
    Join Date
    May 2009
    Posts
    76

    Default

    Amy,

    In AppConfig, check the value for "UseSKUForProductImageName."

    Dayhawk

    [Updated: Scratch the AppConfig. I missed the alt text part of the question. The image alt text is stored in Add/Edit Product > Search Engine > Alt Text under the Product menu in the Admin section. If you'd like to set all the image alt texts to equal the product name, simply run the update statement on your SQL Server, as mentioned by esedirect:

    UPDATE Product
    SET SEAltText = Name
    WHERE [Conditions]

    ]
    Last edited by dayhawk; 04-06-2012 at 08:58 AM. Reason: Misread the question.
    MSx 9.2, SQL Server 2005, Windows 2008 R2 Web 64-Bit

  9. #9
    Amy P is offline Member
    Join Date
    Jun 2007
    Posts
    50

    Default

    That is the search engine alt text though not the image alt text. When you right click on an image and look at properties for the image name it displays the productid.jpg

    Maybe I am wrong and I am not meaning to say the alternate text for the image and I am actually wanting to change the image name?

    Instead of it showing the product id I want it to name the image the product name.

  10. #10
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    You're right - when you say you were wrong...

    What you're talking about is indeed the filename rather than the alt text.

    Do you really want all of your images to be named :-

    my really great product name.jpg?



    TTFN

    BFG

  11. #11
    Amy P is offline Member
    Join Date
    Jun 2007
    Posts
    50

    Default

    Yes I want them all to be named their product names. It helps with SEO

  12. #12
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    Running this on our site puts the product name in the Product Variant alt text box

    We just add it to the product xml package

    <xsl:attribute name="alt"><xsl:value-of select="$pName" disable-output-escaping="yes"/></xsl:attribute>

  13. #13
    Amy P is offline Member
    Join Date
    Jun 2007
    Posts
    50

    Default

    No I don't need the product variants alt text to be the product name.

    I need the image to be named the product name instead of product id and I don't know how to do this.

  14. #14
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    This does that for us. See the image attached

    From knowledge the only place that the image alt is stored is within the image area of the product variant. The main product image tab only houses Sizes and Colour Swatch.

    Name:  imagealt.jpg
Views: 30
Size:  139.8 KB

  15. #15
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    Ok I am a bit confused now as your original post says

    "I was wondering if there is an easy way to change the image name alt text instead of it being named it's product id?"

    Now you're saying

    "I need the image to be named the product name instead of product id"

    if you want the Image name to be the product name then I would run a SQL command similair to the one posted earlier using Name as the value to populate the ImageFilename

  16. #16
    Amy P is offline Member
    Join Date
    Jun 2007
    Posts
    50

    Default

    Yeah sorry I was originally confused on what I needed.

    I will try that SQL command

    Thanks for the help

  17. #17
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    No worries.

    Something like

    UPDATE Product SET ImageFilename = Name

    I'd test on a dev database if you have it and backup first.

  18. #18
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Bear in mind that this won't actually change the names of your images though...



    TTFN

    BFG

  19. #19
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    Sorry it should have been

    UPDATE Product SET ImageFilenameOverride = Name

    That will change the name of the image to match the product name and should use the default ASPDSNF image extentions to look for jpg, then gif then png.

    However you would of course need the images to be renamed too, so BFG 9000 is correct there too.
    Last edited by deanfp; 04-06-2012 at 04:07 PM.

  20. #20
    dayhawk is offline Member
    Join Date
    May 2009
    Posts
    76

    Default

    Thanks BFG 9000. ;-)

    Amy: I forget if I added this or if it came out of the box. Would you check in product.SimpleProduct.xml.config package file that the following sections exist:

    In the parameter section of the Product Template

    Code:
    <xsl:param name="AltText">
      <xsl:choose>
        <xsl:when test="aspdnsf:GetMLValue(SEAltText)=''">
          <xsl:value-of select="aspdnsf:GetMLValue(Name)" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="aspdnsf:GetMLValue(SEAltText)" />    
        </xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    and the this xsl value

    Code:
    <xsl:value-of select="aspdnsf:LookupProductImage(ProductID, ImageFilenameOverride, SKU, 'medium', 1, $AltText)" disable-output-escaping="yes"/>
    Dayhawk
    MSx 9.2, SQL Server 2005, Windows 2008 R2 Web 64-Bit

  21. #21
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    So now that we're all on the same page, and what Amy really wanted to know was how to rename all of her image filenames to the names of the products (probably Product.SEName) do we believe it would be better for SEO purposes to do this? Currently our images are named after the Product.ProductID, making them easy to find and control on our servers. As does BFG 9000 at 3MSelect, and I presume a lot of others. Undoubtedly it would make a difference in Google image search, but is it enough of a difference?

    To be able to do this you would need to write a program to read in the ProductID, Name and SETitle and loop through all products changing the image names in the icon, medium and large folders. Achievable if you know enough C#, or other languages.
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  22. #22
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    I don't believe it would make a noticeable difference to SEO.


    That being said though - I think you could easily rename all your images without needing to resort to any programming...


    Here's how I'd do it (this is just a sample of 10 - but you get the ideal):-






















    TTFN

    BFG

  23. #23
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    What a dufus, I am! The number of times I have extolled the virtues of using Excel for doing similar things on this forum, and I forgot about it for this case! Now that's the way to do it
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  24. #24
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    Top Tip! I was using Faststone image changer to do it.