Request smaller featured image sizes from CMS Blog Post API
SOLVE
Hi all!
We have a Wordpress site with a Hubspot blog. We've created a hubspot blog post importer plugin on the Wordpress site to output blog cards on the website's homepage here: https://www.incourage.com/#from-the-blog
I'll give a little background on how our image resizing process works. For automatic resizing on our CMS, the HubSpot CMS basically looks for height and width attributes on <img> tags. So an image like:
And that's similar to what you're seeing in your first image hosted on teamblog.incourage.com: https://teamblog.incourage.com/hs-fs/hubfs/InCourage_Personal_Coach.png?width=500, where the width is appended in a query string to the file URL. The CMS is basically intercepting the request from the File Manager CDN, and then it can use the resizing service to resize the image instead of serving up the original file.
For files hosted in the File Manager (whether hosted on a custom domain like teamblog.incourage.com or on a default domain like cdn2.hubspot.net), those files can be resized if you use the proper URL structure. I'm not entirely sure why it was done this way, but I think it has to do with how our service is able to intercept requests from the CDN. So for images hosted on the default cdn2 domain, you'd need to adjust a URL from this:
And ^that structure matches what you're seeing for your file where the image resizing was done. In the case of your non-resized image, you'll need to change your original URL from:
It will take a little longer to load the image the first time you're loading a new image size, since the image resizing process needs to run. But then it caches the newly resized image, so it will load faster from then on.
It sounds like you're using a plugin to pull content from HubSpot over to WordPress. Is it possible for you to edit the plugin so that it changes the URL structure of those images to follow that new format? That should enable the image resizing to work for you.
I'll see if we can get this documented a bit more formally. But for now, let me know if you have any questions.
I'll give a little background on how our image resizing process works. For automatic resizing on our CMS, the HubSpot CMS basically looks for height and width attributes on <img> tags. So an image like:
And that's similar to what you're seeing in your first image hosted on teamblog.incourage.com: https://teamblog.incourage.com/hs-fs/hubfs/InCourage_Personal_Coach.png?width=500, where the width is appended in a query string to the file URL. The CMS is basically intercepting the request from the File Manager CDN, and then it can use the resizing service to resize the image instead of serving up the original file.
For files hosted in the File Manager (whether hosted on a custom domain like teamblog.incourage.com or on a default domain like cdn2.hubspot.net), those files can be resized if you use the proper URL structure. I'm not entirely sure why it was done this way, but I think it has to do with how our service is able to intercept requests from the CDN. So for images hosted on the default cdn2 domain, you'd need to adjust a URL from this:
And ^that structure matches what you're seeing for your file where the image resizing was done. In the case of your non-resized image, you'll need to change your original URL from:
It will take a little longer to load the image the first time you're loading a new image size, since the image resizing process needs to run. But then it caches the newly resized image, so it will load faster from then on.
It sounds like you're using a plugin to pull content from HubSpot over to WordPress. Is it possible for you to edit the plugin so that it changes the URL structure of those images to follow that new format? That should enable the image resizing to work for you.
I'll see if we can get this documented a bit more formally. But for now, let me know if you have any questions.
Request smaller featured image sizes from CMS Blog Post API
SOLVE
No prob and thanks again for your solution.
I got another commnuity badge out of posting that first reply. So with one post and one reply I now have 83 hubspot badges. Maybe 85 if there is a badge for posting a second reply and starting a two day reply streak..