[js-embedded-discovery] branch main updated: EDS-87 EDS image selection enhancements

Rod Widdowson rdw at steadingsoftware.com
Tue Jun 10 13:01:39 UTC 2025


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository js-embedded-discovery.

View the commit online:
http://git.shibboleth.net/view/?p=js-embedded-discovery.git;a=commit;h=75d1076d1e253b26f653f756a7a0c508806eac94

The following commit(s) were added to refs/heads/main by this push:
     new 75d1076  EDS-87 EDS image selection enhancements
75d1076 is described below

commit 75d1076d1e253b26f653f756a7a0c508806eac94
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jun 10 13:38:46 2025 +0100

    EDS-87 EDS image selection enhancements
    
    https://shibboleth.atlassian.net/browse/EDS-87
    
    The generated drop down list will pick *any* square logo and scale it appropriately
    subject to the previous rules on language (no language specified or languages match)
    
    For the "previously selected list":
    
    As now, the best match for the aspect ratio amongst logos carrying the appropriate
    language will be taken.
    
    But if not is found then the best fit to aspect ration is chose in a language blind
    manner.
---
 src/javascript/idpselect.js | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/javascript/idpselect.js b/src/javascript/idpselect.js
index 3bb0854..f588b0f 100644
--- a/src/javascript/idpselect.js
+++ b/src/javascript/idpselect.js
@@ -658,28 +658,44 @@ function IdPSelectUI() {
             // See GetLocalizedEntry
             //
             var bestFit = null;
+            var bestFitAnyLang = null;
             var i;
             if (null == idp.Logos) {
                 return null;
             }
+    
             for (i in idp.Logos) {
-                if (idp.Logos[i].lang == language &&
-                    idp.Logos[i].width != null &&  
+                if (idp.Logos[i].width != null &&
                     idp.Logos[i].width >= minWidth &&
-                    idp.Logos[i].height != null && 
+                    idp.Logos[i].height != null &&
                     idp.Logos[i].height >= minHeight) {
-                    if (bestFit === null) {
-                        bestFit = idp.Logos[i];
+                    if (bestFitAnyLang == null) {
+                        bestFitAnyLang = idp.Logos[i];
+                    }
+
+                    if (idp.Logos[i].lang == language) {
+                        if (bestFit === null) {
+                            bestFit = idp.Logos[i];
+                       } else {
+                           me = Math.abs(bestRatio - Math.log(idp.Logos[i].width/idp.Logos[i].height));
+                           him = Math.abs(bestRatio - Math.log(bestFit.width/bestFit.height));
+                           if (him > me) {
+                               bestFit = idp.Logos[i];
+                           }
+                       }
                     } else {
                         me = Math.abs(bestRatio - Math.log(idp.Logos[i].width/idp.Logos[i].height));
-                        him = Math.abs(bestRatio - Math.log(bestFit.width/bestFit.height));
+                        him = Math.abs(bestRatio - Math.log(bestFitAnyLang.width/bestFitAnyLang.height));
                         if (him > me) {
-                            bestFit = idp.Logos[i];
+                            bestFitAnyLang = idp.Logos[i];
                         }
                     }
                 }
             }
-            return bestFit;
+            if (bestFit != null) {
+                return bestFit;
+            }
+            return bestFitAnyLang;
         } ;
 
         var bestFit = null;
@@ -1294,7 +1310,7 @@ function IdPSelectUI() {
         for (i =0; i < idp.Logos.length; i++) {
             var logo = idp.Logos[i];
 
-            if (logo.height == "16" && logo.width == "16") {
+            if (logo.height == logo.width) {
                 if (null == logo.lang ||
                     lang == logo.lang ||
                     (typeof majorLang != 'undefined' && majorLang == logo.lang) ||

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list