Extension talk:AdaptiveThumb/Archive 1

From mediawiki.org


wrong directory name in the zip

> extensions# unzip master.zip

> A new folder $IP/extensions/adaptivethumb will be added. Make sure its owner:group is www-data:www-data or whatever you apache is running as:

Unfortunately the extracted directory is "$IP/extensions/adaptivethumb-master" and this forces "require_once("$IP/extensions/adaptivethumb/adaptivethumb.php");" to break my wiki.

So either change the require_once command or the packaged directory.

I think I fixed it, could you try again following the documentation? Thanks! --ThorstenStaerk (talk) 16:41, 28 January 2015 (UTC)Reply
Only partially. Your fix only works once. If you would try to reinstall the extension using your method it would result in a subdirectory adaptivethumb-master inside adaptivethumb (Fabian Herschel)

example does not work

key/value-pair size=30% does not work. This has the following reason

  • Your paramer in the extension is called "width" and not "size" ;-)
OMG so good to have you. Fixed. --ThorstenStaerk (talk) 16:35, 28 January 2015 (UTC)Reply

patch to support adaptive images in tables and outside

The following patch intruces a parameter "mode" which could be left empty or set to "table". This parameter controls whether the image is embedded in a table or not.

 --- adaptivethumb.php.orig	2015-01-28 19:19:52.068826899 +0100
 +++ adaptivethumb.php	2015-01-28 19:59:18.457788756 +0100
 @@ -1,4 +1,4 @@
 -?php
 +<?php
  
  // <pic src="/mindmap.jpg" size=30% align=right caption="this is a mindmap" />
  
 @@ -16,23 +16,20 @@
    $width=htmlentities($argv['width']); // needn't be numeric, could be "50%"
    $src=htmlentities($argv['src']);
    $caption=htmlentities($argv['caption']);
 +  $mode=htmlentities($argv['mode']);
    if (empty($align)) {$align="right";};
    if (empty($width)) {$width="100%";};
 -  $result="<div style=\"border:1px;solid;color=\"cccccc\">
 -<table width=$width border=1 align=$align>
 -<tr border=0>
 -<td style=\"border:0px\">
 -<img src=$src width=100% />
 -</td>
 -</tr>
 -<tr>
 -<td style=\"border:0px\" align=center>
 -$caption
 -</td>
 -</tr>
 -</table>
 -</div>
 -";
 +  if ($mode == "table") {
 +    $mytable1="<table width=$width border=2 align=$align>
 +      <tr border=0><td style=\"border:0px\">";
 +    $mytable2="</td><tr><td style=\"border:0px\" align=center>
 +      $caption</td></tr></table>";
 +    $myimage="<img src=$src width=100% />";
 +  } else {
 +    $mytable1=""; $mytable2="";
 +    $myimage="<img src=$src width=$width />";
 +  }
 +  $result="<div style=\"border:1px;solid;color=\"cccccc\"> $mytable1 $myimage $mytable2 </div>";
    $result=preg_replace("/\n/","",$result);
    return $result;
  }

--FabianHerschel (talk)

I love programming together, thanks for the patch. As a little nit-pick, you forgot the "align" parameter in the else branch. But you thought of security with htmlentities, good :) --ThorstenStaerk (talk) 07:17, 30 January 2015 (UTC)Reply
committed and pushed: https://github.com/tstaerk/adaptivethumb/commit/4bd7f97a54126dd23dd87e45aa6b18ed3f5d353a#diff-f8783d5dfc1347ef46b819f6541887db Please note this will change a lot, table mode should be switched on if and only if there is a caption. --ThorstenStaerk (talk) 08:24, 30 January 2015 (UTC)Reply

--catterz

Great extension, but it doesn't work out of the box for me unless I specify the full path of the image. MediaWiki seems to organise uploaded files in different folders, so I have to explicitly reference the relative folder path to the file as well for it to show up. With the [[File:...]] tag, MediaWiki figures the relative path out and you only need to reference the file name. Is there any way to change that in the extension?
ie. [[File:image.png]]
becomes
<pic src="/images/4/4e/image.png" />