<?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>Rob Yardman &#187; Wordpress Image Control</title>
	<atom:link href="http://www.robyardman.com/tag/wordpress-image-control/feed" rel="self" type="application/rss+xml" />
	<link>http://www.robyardman.com</link>
	<description>Switching gears in life...</description>
	<lastBuildDate>Tue, 07 Feb 2012 21:17:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Controlling Image Sizes In WordPress</title>
		<link>http://www.robyardman.com/wordpress/controlling-image-sizes-in-wordpress?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=controlling-image-sizes-in-wordpress</link>
		<comments>http://www.robyardman.com/wordpress/controlling-image-sizes-in-wordpress#comments</comments>
		<pubDate>Fri, 26 Mar 2010 02:55:00 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Clients]]></category>
		<category><![CDATA[Beginning WordPress]]></category>
		<category><![CDATA[CMS Image Control]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Wordpress Client]]></category>
		<category><![CDATA[Wordpress Designer]]></category>
		<category><![CDATA[Wordpress Image Control]]></category>
		<category><![CDATA[Wordpress Images]]></category>
		<category><![CDATA[WordPress Theme]]></category>
		<category><![CDATA[WordPress Theming]]></category>

		<guid isPermaLink="false">http://www.robyardman.com/?p=464</guid>
		<description><![CDATA[When building a Content Management System for a client, one of the main concerns for a designer is image sizes. If your client is going to be uploading and inserting images into their pages and blog posts then you want the integrity of the design to remain intact; while still allowing your client the freedom [...]
Related posts:<ol>
<li><a href='http://www.robyardman.com/news/wordpress-client-the-santa-fe-vip' rel='bookmark' title='WordPress Client: The Santa Fe VIP'>WordPress Client: The Santa Fe VIP</a></li>
<li><a href='http://www.robyardman.com/wordpress/more-into-wordpress-vs-joomla-and-a-new-rob-theme' rel='bookmark' title='More WordPress Vs. Joomla and a New Theme'>More WordPress Vs. Joomla and a New Theme</a></li>
<li><a href='http://www.robyardman.com/news/design-inspiration-education' rel='bookmark' title='Design, Inspiration &amp; Education'>Design, Inspiration &#038; Education</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.robyardman.com/wp-content/uploads/2010/03/image-width.jpg" rel="lightbox[464]"><img class="alignright size-full wp-image-470" title="image-width" src="http://www.robyardman.com/wp-content/uploads/2010/03/image-width.jpg" alt="" width="150" height="150" /></a>When building a Content Management System for a client, one of the main concerns for a designer is image sizes. If your client is going to be uploading and inserting images into their pages and blog posts then you want the integrity of the design to remain intact; while still allowing your client the freedom to post media without the concern of breaking stuff.</p>
<p>No one wants to open their web page only to see that a huge, or mis-managed, image has pushed content off to the side and completely damaged any credibility of the website to its current or potential readers. Typically this isn&#8217;t due to a lack of caring by the author. It&#8217;s usually an issue of content providers not understanding the complexities of image sizes and resolutions in relation to web design an content authoring.<span id="more-464"></span></p>
<p>This problem came to me during a recent project where my client was posting images and content on a daily basis. I needed a way to constrain the pixel size of images that were being uploading to the server and into articles. I found myself spending a great deal of time re-editing and re-inserting images that were being published way too large. It became a tedious problem after a while and I needed a solution that would benefit me and still give my client the comfort of knowing he wasn&#8217;t damaging his own website.</p>
<h2>The Easy Way Out</h2>
<p>Okay, so there is a simple CSS trick ( <span class="span-code" style="color: #ff6600;">img { max-width: 500px; }</span> ) that you can use to fix this problem. Using CSS width limits on &#8220;img&#8221; html tags will constrain the maximum width an image is displayed in the browser. However, this approach is a little funky and the image isn&#8217;t actually optimized at the specified width. It&#8217;s only scaled down, or &#8220;squeezed&#8221; by the browser, so it&#8217;s still not an ideal solution because you&#8217;re rendering an image that&#8217;s at a resolution way too large for web optimization. I needed a solution that would re-optimize the image to fit into the content space and be at a resolution that&#8217;s suitable for web publishing.</p>
<p>After a couple days of research I found a WordPress extention and an easy code hack that could help me get what I needed.</p>
<h2>My Requirements</h2>
<p>First of all, I want the maximum size of the image uploaded onto the web server to be no larger than 980 pixels in width. This is an optimal image size that will display a perfectly proportioned image when its thumbnail is clicked. A full sized picture is displayed by Lightbox that&#8217;s not larger than the width of the web page (1,010 pixels wide).</p>
<p>In order to achieve this I installed <a title="Resize At Upload Plus" href="http://wordpress.org/extend/plugins/resize-at-upload-plus/">Resize at Upload Plus</a> through the WordPress plugin library. This plugin was written by Daniel Mores and A. Huizingais. It lets you set the maximum size an image can be uploaded onto the web server. If the image is larger than that maximum size, the plugin resizes it to whatever size and width you specify. It&#8217;s a really sweet and simple plugin and something I would hope to see built into WordPress in future updates.</p>
<p style="text-align: center;"><a href="http://www.robyardman.com/wp-content/uploads/2010/03/resize-at-upload.png" rel="lightbox[464]"><img class="aligncenter size-medium wp-image-485" title="Resize At Upload Screen" src="http://www.robyardman.com/wp-content/uploads/2010/03/resize-at-upload-300x165.png" alt="" width="300" height="165" /></a></p>
<p><a title="Resize At Upload Plus" href="http://wordpress.org/extend/plugins/resize-at-upload-plus/">Resize at Upload Plus</a> solves a lot for me. Now my client can upload images directly from his digital camera or computer and not have to worry about the physical pixel size of the image.</p>
<p>Before I had him resizing his images in Photoshop before uploading and publishing them. Now my server doesn&#8217;t take such a huge hit with the giant images that were once being uploaded onto it and I&#8217;m not having to spend valuable time to go back and correct these image size issues.</p>
<p>The next part of the problem could be solved natively in WordPress without needing an extension or plugin. WordPress lets content contributors insert images at four different specified sizes: &#8220;Thumbnail Size,&#8221; &#8220;Medium Size,&#8221; &#8220;Large Size,&#8221; and &#8220;Full Size.&#8221; Although the intermediate sizes of the image can be constrained, the &#8220;Full Size&#8221; image option is still going to be a problem since it allows the author to insert an image at a width up to 980 pixels.</p>
<p>In the &#8220;Media&#8221; section I set the &#8220;Thumbnail Size&#8221;, &#8220;Medium Size&#8221; and &#8220;Large Size&#8221; accordingly to fit the content column so that the image would not be larger than it. That was pretty easy.</p>
<p style="text-align: center;"><a href="http://www.robyardman.com/wp-content/uploads/2010/03/media-settings.png" rel="lightbox[464]"><img class="aligncenter size-medium wp-image-489" title="Media Settings" src="http://www.robyardman.com/wp-content/uploads/2010/03/media-settings-300x173.png" alt="" width="300" height="173" /></a></p>
<p>Having solved that problem there was one more item left to address&#8230;</p>
<h2>Solving the &#8220;Full Size&#8221; Problem</h2>
<p>The next problem I was dealing with is that the &#8220;Add Image&#8221; dialog was still allowing the content author the ability to insert an image at its full size of up to 980 pixels.</p>
<p style="text-align: center;"><a href="http://www.robyardman.com/wp-content/uploads/2010/03/add-image.png" rel="lightbox[464]"><img class="aligncenter size-medium wp-image-490" title="Add Image" src="http://www.robyardman.com/wp-content/uploads/2010/03/add-image-300x194.png" alt="" width="300" height="194" /></a></p>
<p>I don&#8217;t want &#8220;Full Size&#8221; to be an option available to the author. It gives them the opportunity to make the mistake of selecting &#8220;Full Size&#8221; and inserting a 980 pixel wide image into an article. Which in effect would break the theme and defeat the purpose of limitations and constraints.</p>
<p>The easiest way to solve this is to disable the code that displays the &#8220;Full Size&#8221; option. Although considered a &#8220;hack&#8221; to the core WordPress files it solves my problem. The particular portion of code we need to disable is located in the <span class="span-code" style="color: #ff6600;">/wp-admin/includes/media.php</span> file on line 822.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$size_names</span> <span style="color: #339933;">=</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
&nbsp;
		<span style="color: #0000ff;">'thumbnail'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Thumbnail'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'medium'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Medium'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'large'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Large'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'full'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Full size'</span><span style="color: #009900;">&#41;</span>
&nbsp;
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Change to:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$size_names</span> <span style="color: #339933;">=</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
&nbsp;
		<span style="color: #0000ff;">'thumbnail'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Thumbnail'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'medium'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Medium'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'large'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Large'</span><span style="color: #009900;">&#41;</span><span style="color: #666666; font-style: italic;">/*,
		'full' =&amp;gt; __('Full size')*/</span>
&nbsp;
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Next, save and upload the media.php file to the server, and the option to insert &#8220;Full Size&#8221; images has been removed and is no longer available to the author.</p>
<p><a href="http://www.robyardman.com/wp-content/uploads/2010/03/removed-fullsize.png" rel="lightbox[464]"><img class="aligncenter size-medium wp-image-504" title="removed-fullsize" src="http://www.robyardman.com/wp-content/uploads/2010/03/removed-fullsize-300x95.png" alt="" width="300" height="95" /></a>That&#8217;s it. The fix is as simple as installing an extension and a change to the core admin media.php file.</p>
<p>The only remaining problem with this &#8220;hack&#8221; is that if you ever update WordPress you may need to go back and comment out the &#8220;Full Size&#8221; code again. Other than that, there should be no problems for you or your client. You no longer have to sit with the thought of images breaking your theme and your client is happy with their ability to edit and contribute to their website. Win &#8211; Win situation.</p>
<p style="text-align: center;">
<p>Related posts:<ol>
<li><a href='http://www.robyardman.com/news/wordpress-client-the-santa-fe-vip' rel='bookmark' title='WordPress Client: The Santa Fe VIP'>WordPress Client: The Santa Fe VIP</a></li>
<li><a href='http://www.robyardman.com/wordpress/more-into-wordpress-vs-joomla-and-a-new-rob-theme' rel='bookmark' title='More WordPress Vs. Joomla and a New Theme'>More WordPress Vs. Joomla and a New Theme</a></li>
<li><a href='http://www.robyardman.com/news/design-inspiration-education' rel='bookmark' title='Design, Inspiration &amp; Education'>Design, Inspiration &#038; Education</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.robyardman.com/wordpress/controlling-image-sizes-in-wordpress/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

