Resize the Default Resolution of Thumbnails in Blogger |
Resize the Default Resolution of Thumbnails in Blogger Posted: 11 Nov 2015 10:11 AM PST As promised in part9 we are sharing today the trick to resize Blogspot thumbnails. Blogger stores media thumbnails in dimensions of 72 x 72 pixels in size. All pictures that you upload inside your blog posts are stored inside JSON feed and XML feed with 72px width and 72px height. The thumbnail images are saved originally in small square sized snapshots which if stretched out using CSS distorts the original resolution of the pictures and as a result they are displayed in poor quality resolution. In this tutorial we will fix this problem by changing the original dimensions of the picture in its URL using simple JavaScript technique and using the Recent Posts widget code that we have been using so far. It is just a one liner code and quite easy to implement. Note: Click the Button below to see full list of topics under discussion. Topics List Fact The default resolution of Blogger thumbnails can never be changed using just CSS. It requires JavaScript to modify the actual URL structure.URL structure of Thumbnails in JSON feedYou clearly know now that thumbnails are stored inside the media$thumbnail node and have the following URL structure: If you observer the URL closely you will notice that each URL is assigned a parameter /s72-c/. Because of this parameter each thumbnail is assigned a default size of 72px by 72px i.e. Square image. The thumbnail thus gets a smaller size which when stretched using CSS gives a low quality image as shown below: Our task is to replace this parameter with a custom variable so that the image size can be resized dynamically to any resolution we want by maintaining the aspect ratio. This will auto create a HQ thumbnail with clean and clear resolution. The thumbnail will then appear in its original dimension with no forced width or height sizes. Lets now get straight to interesting but simple coding! Resizing Blogger ThumbnailsWe will use the exact same code for recent posts widget that we shared in Part#9. All the modifications made are highlighted in pink.
How it works? 1. We first declared a variable ImageSize to dynamically adjust the image size parameter from /s72-c/ to /s100-c/. 100px here means /s100-c/ i.e. 100px X 100px. Note that image size can easily be changed using CSS as well like we have done (i.e. width:80px; height:65px). The CSS image size must always be less than or equal to ImageSize but not greater than it else the resolution will collapse. Normally thumbnails are displayed in size of 100px by 100px, if you want much larger thumbnails you can surely increase the value for ImageSize. and then customize the width and height using CSS like we did. 2. We then declared another variable sk and set it to null. 3. The third most important step is:
Here we first used the JavaScript replace () method to replace s72-c with ImageSize. We then saved this new Image URL inside sk. 4. Finally we removed the parameter ?imgmax=800 from the Image URL inside sk using the replace method and saved the new clean URL inside ListImage. Normal Size
Custom Size I made these changes:
See no loss in image quality even if you stretch it to 500px! Need Help?Let me know if you need any assistance till this part of the tutorial series. Do post your questions and let us know if you found any part confusing. In our coming tutorials we will cover Dynamic sliders, carousels and all sorts of animated widgets and much more. This is just the trailer! => Peace and blessings buddies! :) |
You are subscribed to email updates from My Blogger Tricks. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
0 comments:
Post a Comment