[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX]: thumb="mouseover" is failing on PluginIMG

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69447ab15d08f_2a24bf3c856677@gitlab-sidekiq-low-urgency-cpu-bound-v2-547b5c788f-t7pvv.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
eef22ff7 by Grace Nshokano at 2025-12-18T21:57:29+00:00
[FIX]: thumb="mouseover" is failing on PluginIMG
---
* [FIX] plugimg mouseover displaying on popover

See merge request tikiwiki/tiki!8983

- - - - -


2 changed files:

- lib/wiki-plugins/wikiplugin_img.php
- themes/base_files/scss/_tiki-wikipages_and_plugins.scss


Changes:

=====================================
lib/wiki-plugins/wikiplugin_img.php
=====================================
@@ -817,6 +817,7 @@ function wikiplugin_img($data, $params)
     }
 
     $browse_full_image = $src;
+    $browse_full_image_for_popup = $src;
     $srcIsEditable = false;
     ///////////////////////////Get DB info for image size and metadata/////////////////////////////
     if (
@@ -1380,21 +1381,21 @@ function wikiplugin_img($data, $params)
             }
         } elseif ($javaset == 'true') {
             $link = 'javascript:void(0)';
-            $fwidth = empty($fwidth) ? '' : $fwidth;
-            $fheight = empty($fheight) ? '' : $fheight;
-            $popup_params = [ 'text' => $data, 'width' => $fwidth, 'height' => $fheight, 'background' => $browse_full_image];
-            if ($imgdata['thumb'] == 'mousesticky') {
-                $popup_params['sticky'] = true;
+            // Convert SEF URL and add &display parameter for file gallery images
+            $popup_image_url = filter_out_sefurl($browse_full_image_for_popup);
+            if (! empty($imgdata['fileId']) && ! str_contains($popup_image_url, 'display')) {
+                $popup_image_url .= (str_contains($popup_image_url, '?') ? '&' : '?') . 'display';
             }
 
-            if ($imgdata['thumb'] == 'mouseover') {
-                $popup_params['trigger'] = 'hover';
-            }
-            // avoid big images will not be closeable on hover if repsonsive is not set. Fallback to require a click to open and a second click somewhere to close.
-            if ((isset($imgdata['responsive']) && $imgdata['responsive'] != 'y') && ($fwidth > 400 || $fheight > 400)) {
-                $popup_params['trigger'] = 'focus';
+            // Use <img> tag instead of background-image for better responsive behavior
+            $popup_image_html = '<img src="' . htmlspecialchars($popup_image_url, ENT_QUOTES) . '" alt="' . htmlspecialchars($altText, ENT_QUOTES) . '" class="img-popover-image">';
+            $popup_params = ['text' => $popup_image_html, 'fullhtml' => true];
+
+            if ($imgdata['thumb'] == 'mousesticky') {
+                $popup_params['sticky'] = true;
             }
 
+            // Let tiki_popover() and $.tikiPopoverWhereToPlace() handle placement and initialization
             $mouseover = ' ' . smarty_function_popup($popup_params, $smarty->getEmptyInternalTemplate());
         } else {
             if (! empty($imgdata['fileId']) && $imgdata['thumb'] != 'download' && empty($urldisp)) {
@@ -1451,24 +1452,9 @@ function wikiplugin_img($data, $params)
             $style = 'style="float: right;"';
         }
 
-        //Final link string
+        //Final link string - let tiki_popover() handle popover initialization
         $replimg = "\r\t" . '<a href="' . $link . '"' . $style . ' class="internal" ' . $linkrel . $imgtarget . $linktitle
                     . $mouseover . '>' . "\r\t\t" . $replimg . "\r\t" . '</a>';
-        if ($imgdata['thumb'] == 'mouseover') {
-            $mouseevent = "$('.internal').popover({
-                          html : true,
-                          placement :wheretoplace
-                          });
-                            function wheretoplace(pop, dom_el) {
-                              var width = window.innerWidth;
-                              if (width<500) return 'bottom';
-                              var left_pos = $(dom_el).offset().left;
-                              if (width - left_pos > 400) return 'right';
-                              return 'left';
-                            }
-                            ";
-            TikiLib::lib('header')->add_jq_onready($mouseevent);
-        }
     }
 
     //Add link string to rest of string


=====================================
themes/base_files/scss/_tiki-wikipages_and_plugins.scss
=====================================
@@ -1195,4 +1195,16 @@ h6:hover .heading-link {
     .viewtextfile-content-wrapper > .viewtextfile-content {
         padding: 20px;
     }
+}
+
+.popover-body .img-popover-image {
+    max-width: 100%;
+    max-height: 80vh;
+    height: auto;
+    display: block;
+    object-fit: contain;
+}
+
+.popover {
+    max-width: none;
 }
\ No newline at end of file



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/eef22ff78d861e59ffd560a5a68c3e307ba73bc0

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/eef22ff78d861e59ffd560a5a68c3e307ba73bc0
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.