<?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>Hdeya team blog &#187; generate</title>
	<atom:link href="http://www.hdeya.com/blog/tag/generate/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hdeya.com/blog</link>
	<description>We can make IT</description>
	<lastBuildDate>Sun, 28 Mar 2010 11:28:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Generate thumbnails automatically for uploaded images on OpenWYSIWYG</title>
		<link>http://www.hdeya.com/blog/2009/05/generate-thumbnails-automatically-for-uploaded-images-on-openwysiwyg/</link>
		<comments>http://www.hdeya.com/blog/2009/05/generate-thumbnails-automatically-for-uploaded-images-on-openwysiwyg/#comments</comments>
		<pubDate>Sat, 02 May 2009 17:18:56 +0000</pubDate>
		<dc:creator>Mahmoud M. Abdel-Fattah</dc:creator>
				<category><![CDATA[PHP Tips]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[automatically]]></category>
		<category><![CDATA[generate]]></category>
		<category><![CDATA[OpenWYSIWYG]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://www.hdeya.com/blog/?p=154</guid>
		<description><![CDATA[We wrote this post specially to integrate openWYSIWYG with jQuery Lightbox, so we recommend you to read this article too <a href="http://www.hdeya.com/blog/2009/05/generates-lightbox-on-the-fly-using-jquery/">http://www.hdeya.com/blog/2009/05/generates-lightbox-on-the-fly-using-jquery/</a>
<a href="http://www.openwebware.com" target="_blank">OpenWYSIWYG </a>is a free &#38; Open source WYSIWYG &#8220;rich text editor&#8221;, and it has a php add-on for images upload. In this post we&#8217;ll describe how to generate thumbnails automatically on images [...]]]></description>
			<content:encoded><![CDATA[<p>We wrote this post specially to integrate openWYSIWYG with jQuery Lightbox, so we recommend you to read this article too <a href="http://www.hdeya.com/blog/2009/05/generates-lightbox-on-the-fly-using-jquery/">http://www.hdeya.com/blog/2009/05/generates-lightbox-on-the-fly-using-jquery/</a></p>
<p><a href="http://www.openwebware.com" target="_blank">OpenWYSIWYG </a>is a free &amp; Open source WYSIWYG &#8220;rich text editor&#8221;, and it has a php add-on for images upload. In this post we&#8217;ll describe how to generate thumbnails automatically on images upload.<span id="more-154"></span></p>
<p>1. Download <a href="http://www.openwebware.com" target="_blank">OpenWYSIWYG</a>, and create a new folder called thumbs inside your uploads folder.</p>
<p>2. Edit /addons/imagelibrary/insert_image.php, add the following code after line 44 :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> createThumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$imageDirectory</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imageName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbDirectory</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbWidth</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$srcImg</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromjpeg</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$imageDirectory</span>/<span style="color: #006699; font-weight: bold;">$imageName</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$origWidth</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$srcImg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$origHeight</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$srcImg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$ratio</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$thumbWidth</span><span style="color: #339933;">/</span><span style="color: #000088;">$origWidth</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$thumbHeight</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$origHeight</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$ratio</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #000088;">$thumbImg</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageCreateTrueColor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbHeight</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">imagecopyresized</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbImg</span><span style="color: #339933;">,</span> <span style="color: #000088;">$srcImg</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbHeight</span><span style="color: #339933;">,</span> <span style="color: #000088;">$origWidth</span><span style="color: #339933;">,</span> <span style="color: #000088;">$origHeight</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$temp_file_name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imageName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp_file_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$temp_file_name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$temp_file_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$thumbImgName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$temp_file_name</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;_thumb.jpg&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #990000;">imagejpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbImg</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$thumbDirectory</span>/<span style="color: #006699; font-weight: bold;">$thumbImgName</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">imagedestroy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbImg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span></pre></div></div>

<p>3. search for :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$upload</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">move_uploaded_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$leadon</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$thumbs_directory</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$leadon</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;thumbs/&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>then add the following code after :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	createThumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$leadon</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbs_directory</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'120'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Finally, open your browser, and try to insert-image through your OpenWYSIWYG, you&#8217;ll find your image uploaded successfully &amp; a generated thumbnail for it found on /thumbs folder.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hdeya.com/blog/2009/05/generate-thumbnails-automatically-for-uploaded-images-on-openwysiwyg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generates lightbox on the fly using jQuery</title>
		<link>http://www.hdeya.com/blog/2009/05/generates-lightbox-on-the-fly-using-jquery/</link>
		<comments>http://www.hdeya.com/blog/2009/05/generates-lightbox-on-the-fly-using-jquery/#comments</comments>
		<pubDate>Sat, 02 May 2009 15:22:03 +0000</pubDate>
		<dc:creator>Mahmoud M. Abdel-Fattah</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Quick Tip / Trick]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[generate]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[on the fly]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://www.hdeya.com/blog/?p=140</guid>
		<description><![CDATA[This method requires you to have  2 copies of each image, the original size &#38; thumbnail one. thumbnails MUST BE named as filename_thumb.jpg &#38; stored in /thumbs.  you must have the latest versions of <a href="code.google.com/p/jqueryjs/downloads/list">jQuery </a>&#38; <a href="http://leandrovieira.com/projects/jquery/lightbox/" target="_blank">jQuery Light Box Plugin</a>. 
then add the following javascript code to you &#60;head&#62;:

$&#40;document&#41;.ready&#40;function&#40;&#41;&#123;
    $&#40;&#34;img&#34;&#41;.each&#40;function&#40;&#41; &#123;
        var src_file = $&#40;this&#41;.attr&#40;&#34;src&#34;&#41;.split&#40;&#34;/&#34;&#41;;
        var src_file_name = src_file.pop&#40;&#41;;
        var patt1 = /_thumb.jpg/;
        var original_file_name = &#34;&#34;;
        if&#40;src_file_name.search&#40;patt1&#41; != -1&#41; &#123;
            original_file_name = src_file_name.replace&#40;/_thumb/gi, &#34;&#34;&#41;;
            $&#40;this&#41;.wrap&#40;&#34;&#38;lt;a href=\&#34;/uploads/&#34;+original_file_name+&#34;\&#34; rel=\&#34;lightbox\&#34;&#38;gt;&#38;lt;/a&#38;gt;&#34;&#41;;
        &#125;
    &#125;&#41;;
    $&#40;&#34;a[rel*=lightbox]&#34;&#41;.lightBox&#40;&#41;;
&#125;&#41;;

]]></description>
			<content:encoded><![CDATA[<p>This method requires you to have  2 copies of each image, the original size &amp; thumbnail one. thumbnails MUST BE named as <strong>filename_thumb.jpg</strong> &amp; stored in <strong>/thumbs</strong>.  you must have the latest versions of <a href="code.google.com/p/jqueryjs/downloads/list">jQuery </a>&amp; <a href="http://leandrovieira.com/projects/jquery/lightbox/" target="_blank">jQuery Light Box Plugin</a>. <span id="more-140"></span></p>
<p>then add the following javascript code to you &lt;head&gt;:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;img&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> src_file <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> src_file_name <span style="color: #339933;">=</span> src_file.<span style="color: #660066;">pop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> patt1 <span style="color: #339933;">=</span> <span style="color: #339933;">/</span>_thumb.<span style="color: #660066;">jpg</span><span style="color: #339933;">/;</span>
        <span style="color: #003366; font-weight: bold;">var</span> original_file_name <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>src_file_name.<span style="color: #660066;">search</span><span style="color: #009900;">&#40;</span>patt1<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            original_file_name <span style="color: #339933;">=</span> src_file_name.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/_thumb/gi</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">wrap</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&amp;lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>/uploads/&quot;</span><span style="color: #339933;">+</span>original_file_name<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> rel=<span style="color: #000099; font-weight: bold;">\&quot;</span>lightbox<span style="color: #000099; font-weight: bold;">\&quot;</span>&amp;gt;&amp;lt;/a&amp;gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a[rel*=lightbox]&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">lightBox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hdeya.com/blog/2009/05/generates-lightbox-on-the-fly-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
