Forums / General Questions / zen_image: Why the extra spaces in the title= attribute?

zen_image: Why the extra spaces in the title= attribute?

Views: 1,150

Results 1 to 9 of 9
13 May 2015, 2:50 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,116
Plugin Contributions:
56

zen_image: Why the extra spaces in the title= attribute?

Is there a reason why the zen_image function (in /includes/functions/html_output.php) adds a space before and after the alt-text when creating the title= attribute for the <img> tag?

    if (zen_not_null($alt)) {
      $image .= ' title=" ' . zen_output_string($alt) . ' "';
    }
13 May 2015, 6:49 PM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: zen_image: Why the extra spaces in the title= attribute?

lat9:

Is there a reason why the zen_image function (in /includes/functions/html_output.php) adds a space before and after the alt-text when creating the title= attribute for the <img> tag?

if (zen_not_null($alt)) {
  $image .= ' title=" ' . zen_output_string($alt) . ' "';
}

Readability?   
Remnants of someone trying to figure out what quotes needed to go where?  

To avoid accidental concatenation of elements? (especially for screen readers)   

Other than these, I can't think of any functional reason for it. 

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

13 May 2015, 8:12 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,116
Plugin Contributions:
56

Re: zen_image: Why the extra spaces in the title= attribute?

RodG:

Readability?
Remnants of someone trying to figure out what quotes needed to go where?

To avoid accidental concatenation of elements? (especially for screen readers)

Other than these, I can't think of any functional reason for it.

Cheers
RodG
Exactly!

14 May 2015, 6:19 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: zen_image: Why the extra spaces in the title= attribute?

Been there since 2004 in v1.1.4 ... maybe was needed way back when and never changed ... :lookaroun

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

14 May 2015, 7:09 PM
#5
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,116
Plugin Contributions:
56

Re: zen_image: Why the extra spaces in the title= attribute?

Thanks, Ajeh! I'll get them gone ...

14 May 2015, 8:20 PM
#6
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: zen_image: Why the extra spaces in the title= attribute?

http://www.w3.org/TR/xhtml1/diffs.html#h-4.7

The user agent spec says they should stripped (although it seems they do not), and Total Validator flags them as an error.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

3 Oct 2015, 6:44 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: zen_image: Why the extra spaces in the title= attribute?

Got bored and hunted through old code ... this was actually inherited from osC a bazillion years ago and never changed ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Apr 2019, 3:27 PM
#8
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: zen_image: Why the extra spaces in the title= attribute?

ZC156: still exists in several places.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

11 Sep 2019, 4:51 PM
#9
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: zen_image: Why the extra spaces in the title= attribute?

fixed in ZC157. Breathe easy again.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...