
- #Wordpress resize images for mobile how to
- #Wordpress resize images for mobile update
- #Wordpress resize images for mobile code
image should not be reduce under this width Public partial class MobileImageResizer : .Page To not give anomalies, I also introduce a minimum width and height, not to go below. Then I made the supposition that the images are optimized for 800×600 and I will reduce the image proportionally to the maximum width and height supported by the mobile device. 😀īut before, one more thing: what is the new size of the image? First of all we need the maximum image width and height supported by the user mobile device.
#Wordpress resize images for mobile code
I will include here only the C# code with enough comments so I won’t need to say anything else. For more information see Mobile device recognition.
#Wordpress resize images for mobile how to
The advantage as a page is that you can process this way, even images from other servers.Īs for how to recognize the user mobile device, we will use my favorite, WURFL.
This can also be implemented as an HTTP filter as well: every time an image is requested, it gets the original image, resizes it and pushes it into the response. The page is taking only one parameter ( i), which is the URL of the original image, downloads it, resizes it and sends it back to the client. Next, I will present a short and practical solution, implemented as an aspx page.
user experience, when it comes to rendering capabilities. performance, when it comes to bandwidth. mobile devices supports web pages only up to a certain total size (page + resources). mobile devices supports images only up to a certain image width and height. mobile devices supports images only up to a certain file size. There are pretty good reasons for doing it: I suspect that this ultimately comes down to some pattern around state and how props are passed down to inner blocks, but haven't been able to pinpoint exactly what the issue is.If you decide that your mobile website won’t be nothing more than a translation of your website, then you have to look into resizing the images too. I found a couple of other issues around how inner blocks render that may or may not be relevant: How to trigger a rerender of innerblocks when parent attribute is changed WordPress/gutenberg#11776 and Calling InnerBlocks with different props doesn't trigger a re-render WordPress/gutenberg#13289. Attempting hacky solutions for forcing a re-render (such as those outlined in this tutorial) didn't resolve the issue. The images resize as expected after tapping anywhere in the editor, indicating that the block (either the Tiled Gallery or the inner image blocks) just need to re-render. I'm not sure why the images resize with no problems when going from to two to one column (i.e. The issue is only visible when images are resized from small to big. onContainerLayout() here is called within the image block when the container size changes. The core Gallery block doesn't have this issue as its images have a fixed height. As the block isn't re-rendered, the height stays the same and only the width updates.
#Wordpress resize images for mobile update
An update to the number of columns only changes the columnWidths value of an image's column/container here, not the height. I haven't been able to get to a solution after some time looking, but wanted to share my notes in cases they're helpful for future reference.