<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>malditoraton.com &#187; plugin</title>
	<atom:link href="http://www.malditoraton.com/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.malditoraton.com</link>
	<description>Va a acabar conmigo</description>
	<lastBuildDate>Sat, 09 Jan 2010 18:46:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Modificar Random Image Selector</title>
		<link>http://www.malditoraton.com/modificar-random-image-selector/</link>
		<comments>http://www.malditoraton.com/modificar-random-image-selector/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 22:18:20 +0000</pubDate>
		<dc:creator>Marat</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.malditoraton.com/?p=41</guid>
		<description><![CDATA[Random Image Selector es plugin de WordPress para presentar imágenes aleatorias de un directorio determinado.
Presenta, entre sus opciones, la posibilidad de seleccionar cómo se va a redimensionar la imagen, fijando el ancho, calcula el alto; fijando el alto, calcula el ancho. La tercera opción &#8220;Constraint both width an height&#8221; fija ambas medidas.
El problema de esta [...]]]></description>
			<content:encoded><![CDATA[<p><a title="WordPress - RIS" href="http://wordpress.org/extend/plugins/random-image-selector/" target="_blank">Random Image Selector</a> es plugin de WordPress para presentar imágenes aleatorias de un directorio determinado.</p>
<p>Presenta, entre sus opciones, la posibilidad de seleccionar cómo se va a redimensionar la imagen, fijando el ancho, calcula el alto; fijando el alto, calcula el ancho. La tercera opción &#8220;Constraint both width an height&#8221; fija ambas medidas.</p>
<p>El problema de esta última opción es, que las imágenes rectangulares (la mayoría), son deformadas para caber exactamente en el cuadrado definido por ambas medidas, como se muestra en la siguiente imagen tomada de <a title="Imagen de rjime31 en flickr" href="http://flickr.com/photos/elitro/2690336554/" target="_blank">Flickr</a>.<span id="more-41"></span></p>
<table style="height: 282px;" border="0" width="232">
<tbody>
<tr>
<td align="center"><img class="aligncenter size-full wp-image-46" title="gusano" src="http://malditoraton.com/wp-content/uploads/2009/02/gusano.jpg" alt="gusano" width="160" height="240" /></td>
<td align="center"><img class="aligncenter size-full wp-image-47" title="gusano2" src="http://malditoraton.com/wp-content/uploads/2009/02/gusano2.jpg" alt="gusano2" width="240" height="240" /></td>
</tr>
<tr>
<td align="center">Imagen original</td>
<td align="center">Imagen mostrada por Random Image Selector</td>
</tr>
</tbody>
</table>
<p>La solución pasa por editar el archivo que se encuentra en ../wp-content/plugins/random-image-selector/randomImage.php. Entre la línea 220 y 238 ( en la versión 1.5.4) encontramos el siguiente código:</p>
<pre> switch($scaleOption)
    {
      case 'high':
	$ratio = $physHeight / $scaleHeight;
        $physWidth = $physWidth / $ratio;
        $physHeight = $scaleHeight;
	break;
      case 'wide':
	$ratio = $physWidth / $scaleWidth;
        $physHeight = $physHeight / $ratio;
        $physWidth = $scaleWidth;
	break;
      case 'spec':
	$physHeight = $scaleHeight;
	$physWidth = $scaleWidth;
	break;
      default:
	break;
    }</pre>
<p>&nbsp;</p>
<p>que deberemos sustituir por este otro:</p>
<pre>//***********Copy from here****************
// Modificado por http://www.malditoraton.com
 switch($scaleOption)
    {
      case 'high':
	$ratio = $physHeight / $scaleHeight;
        $physWidth = $physWidth / $ratio;
        $physHeight = $scaleHeight;
	break;
      case 'wide':
	$ratio = $physWidth / $scaleWidth;
        $physHeight = $physHeight / $ratio;
        $physWidth = $scaleWidth;
	break;
      case 'spec':
	if ($physHeight &lt; $physWidth){
	$ratio = $physWidth / $scaleWidth;
	$physWidth = $scaleWidth;
        $physHeight = $physHeight / $ratio;
	}else{
	$ratio = $physHeight / $scaleHeight;
	$physHeight = $scaleHeight;
        $physWidth = $physWidth / $ratio;
	}
	break;
      default:
	break;
    }
//**************to here************************</pre>
<p>&nbsp;</p>
<p>y la imagen os la devolverá perfectamente ajustada, para que quepa sin deformación en una ventana definida por las medidas para las que se ha configurado el plugin. Si preferís no editar código podeis descargar la versión completa desde este enlace <a href="http://malditoraton.com/wp-content/uploads/2009/02/random-image-selector.zip">random-image-selector</a></p>
<p class="akst_link"><a href="http://www.malditoraton.com/?p=41&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_41" class="akst_share_link" rel="nofollow">Compártelo</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://www.malditoraton.com/modificar-random-image-selector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
