Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to extract string with regex
    primarykey
    data
    text
    <p>I'm using a this technic for resizing images on-the-fly, that uses the .htaccess and some php script.</p> <p>in the .htaccess i have this:</p> <pre><code># BEGIN ImageResizing &lt;ifmodule mod_rewrite.c&gt; RewriteEngine on RewriteBase / RewriteRule ^img-small/([A-Za-z0-9/_-]+).(jpg|gif|png)$ images.php?max_width=100&amp;imgfile=$1.$2 &lt;/ifmodule&gt; # END ImageResizing </code></pre> <p><a href="http://sneak.co.nz/projects/img-resizing/php-resizing-v2.zip" rel="nofollow">images.php</a> is the script that does the actual resize</p> <p>this regex expression:</p> <pre><code>^img-small/([A-Za-z0-9/_-]+).(jpg|gif|png)$ </code></pre> <p>matches this path:</p> <pre><code>http://yoursite.com/img-large/myimagepath/myimage.jpg </code></pre> <p>and then sends it to the images.php script as arguments $1.$2</p> <pre><code>images.php?max_width=100&amp;imgfile=$1.$2 </code></pre> <p>My question is: How can I make this work if I have a path like this:</p> <pre><code>http://yoursite.com/myimagepath/min_myimage.jpg </code></pre> <p>I tried to to build a expression like this:</p> <pre><code>^([A-Za-z0-9/_-]+/)+(min_)([A-Za-z0-9]+).(jpg|gif|png)$ </code></pre> <p><a href="https://www.debuggex.com/r/V-2URp3iB01ZuoLK" rel="nofollow">Debuggex Demo</a></p> <p>I think the problem is on the second part of the RewriteRule</p> <pre><code>images.php?max_width=100&amp;imgfile=$1.$2 </code></pre> <p>I tried to change to something like:</p> <p>images.php?max_width=100&amp;imgfile=$1+$3.$4</p> <p>this is the firt lines of the php script:</p> <pre><code>// max_width and image variables are sent by htaccess $max_height = 1000; $image = $_GET["imgfile"]; $max_width = $_GET["max_width"]; if (strrchr($image, '/')) { $filename = substr(strrchr($image, '/'), 1); // remove folder references } else { $filename = $image; } $size = getimagesize($image); $width = $size[0]; $height = $size[1]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload