CodeIgniter image_lib bug in the image process loop

This bug has me scratch my head for hours and finally found the solutions to fix it.

In CodeIgniter, you can upload multiple images and do resize, crop and watermark stuff. It's cool that you can use one library to do many awesome stuff. However there is problem when using image_lib in the loop.

Problem:

I upload few image and want to loop through each one of them and resize them differently based on their original size. So I put the resize function in the loop. However, the dimension is based on the previous image.

For example. the first image is resized to 100x200. The second image should be resize to 50x100, but is resized to 100x200. The third one should be resized to 400x300, but is resized to 100x75.

In other words, the second image was resized using the dimension from the previous resized image based on the second image's longer side (W or H). The first image was resized to 100x200, so the second image was resized to 100x200 because the original dimension of the second image was 50x100 (Height is larger than width). So it take the first image's height to resize the second images. Crap!


Solutions:
In the image_lib in CodeIgniter, there is a function to clean the setting ($config). However, there is missing parameters in the function.

So I add two lines in the function clear().

$this->width = '';
$this->height = '';
Add the above two lines before closing the function.

Problem solved!

Facebook Social Plugin load page twice on Firefox and Google Chrome

There is weird issues with FireFox and Google Chrome. The page will be loaded twice, if Facebook Social Plugin such as LIKE button installed on your site.

There is a solution post on Terence Chang's blog!

Prevent Facebook Social Plugin to load page twice – CodeIgniter

iPhone is not recoganized on XP / Vista as Camera drive

In some case, the USB driver was not working right so iPhone is not recognized as camera drive or external storage drive.

Here are the step to make it works.

  1. Connect your iPhone by USB
  2. Open Windows Device Manager (right-click My Computer and select Manage). You may find your iPhone under “Universal Serial Bus Controllers” or possibly under “Portable Devices”.  At any rate if your phone can sync with iTunes it will be in there somewhere.  It should be called Apple Mobile Device USB Driver.
  3. Right-click and select “Uninstall” but don’t remove the files from the PC.
  4. Disconnect your iPhone and reconnect. You should see the iPhone showing as one of the camera drive or external storage.

In case you still not seeing your iPhone showing up. Make sure you have at least one photo in your Camera Roll.

Fix YouTube overlay issues with WordPress Menubar

Problem:
YouTube Video is covering up the menu bar. It's due to the flash play that has the top priority.
 
Solutions: 
Add the wmode=opaque parameter to the embed code. 

< object width="460" height="307" VIEWASTEXT>
 < param name="movie" value="src="YOUR_YOUTUBE_URL_HERE"">
 < param name="allowFullScreen" value="true">
 < param name="allowscriptaccess" value="always">
 < param name="wmode" value="opaque" />
 < embed src="YOUR_YOUTUBE_URL_HERE"
  type="application/x-shockwave-flash"
  allowscriptaccess="always"
  allowfullscreen="true"
  width="460"
  height="307"
  wmode="opaque">
 < /embed>
< /object>