Dynamic Content - Choose Image Size?

When I am using the Dynamic Content functionality to display an “Image” sourced from the “Featured Image” of the post/page, I’m using:

{{dc:post:featured_image}}

But this is pulling the ‘raw’ full image size. Which isn’t ideal, since it’s not being displayed at full resolution - it’s being used as a thumbnail. Is there a way to force it to use the “Medium” or “Thumbnail” sizing defaults?

thanks!

1 Like

Hello @dgoldwas,

Thanks for writing to us.

Regretfully, there is no option to display different size of featured image of Page/Posts. It would require custom development. I would suggest you contact a developer who can assist you with your concern or you can avail our service called One, where the customization questions are answered.

Please note that we don’t provide custom development and customization support. It is out of the support scope.

Thanks for understanding

That’s too bad… right now when choosing an image, the Media Library popup lets us pick the size. Dynamic Content should allow us to declare the same variable… if you could please add it as a feature request, that would be appreciated.

Projects-Content-Pro

2 Likes

Hello @dgoldwas

Thanks for your suggestion, we will take it as a feature request and it will be informed to our development team.

Have a great day!
Thnaks

I have the same problem. You have created great post elements, but because of big images, pages built with Pro will be heavy, slow for users- especially on mobile devices(almost 90% on my site) and with bad position in the Google .

For now I am using Wordpress custom field with manually inserted link to the small image. You can pick it in the Dynamic Content window -> Post-> Meta (Custom Field).

best regads,
sylwek.

I have found a workaround for this issue. But first, please keep in mind, that I am not an developer and I am not really know what I am doing :wink: It is working in my environment, but please check this workaround on your test site before running on production servers.

I have prepared simple wp function which is saving post featured image urls in the custom fields(featured_thumbnail_url, _featured_medium_url and _featured_large_url) on post save/ update. You can add the following code to the functions.php file:

//save featured image urls in the post custom fields
function save_featured_image_urls($id)
{
$featured_id = (int)get_post_thumbnail_id($id);
if (has_post_thumbnail( $id ) )
{
$thumbnail_url = wp_get_attachment_image_url( $featured_id, ‘post-thumbnail’ );
update_post_meta($id, ‘_featured_thumbnail_url’, $thumbnail_url);
$medium_url = wp_get_attachment_image_url( $featured_id, ‘post-medium’ );
update_post_meta($id, ‘_featured_medium_url’, $medium_url);
$large_url = wp_get_attachment_image_url( $featured_id, ‘post-large’ );
update_post_meta($id, ‘_featured_large_url’, $large_url);
}
}
add_action(‘save_post’, ‘save_featured_image_urls’);

I have also prepared some code which you can temporary add to the functions.php to update all posts with these custom fields. Run it once and delete it to avoid constant data update.

/ get all posts from blog
$query = new WP_Query(
array(
‘post_type’ => ‘post’,
‘posts_per_page’ => -1,
)
);
$all_posts = $query->posts;

foreach ($all_posts as $one_post) //set custom fields for all posts
{
$featured_id = (int)get_post_thumbnail_id($one_post->ID); //get featured image ID
if ($featured_id != 0)
{
$thumbnail_url = wp_get_attachment_image_url( $featured_id, ‘post-thumbnail’ );
update_post_meta($one_post->ID, ‘_featured_thumbnail_url’, $thumbnail_url);
$medium_url = wp_get_attachment_image_url( $featured_id, ‘post-medium’ );
update_post_meta($one_post->ID, ‘_featured_medium_url’, $medium_url);
$large_url = wp_get_attachment_image_url( $featured_id, ‘post-large’ );
update_post_meta($one_post->ID, ‘_featured_large_url’, $large_url);
}
}

/* Restore original Post Data */
wp_reset_postdata();

Hi @mosiu,

Thanks for sharing this! Great job getting all that wired up.

In Pro 4 and Cornerstone 5 we have a way to apply a thumbnail size in some cases but it’s a bit of a workaround.

  • Under preferences, enable the Dev Console.
  • Inspect an Image element and open the console
  • Look for image_source and enter {{dc:post:featured_image_id size="medium"}} That size attribute accepts any thumbnail size and will default to full if not set.

This should work for any of the image controls in the builder but because it is just retrieving the attachment ID you can use it for any inline <img> tags that you add directly to your content.

1 Like

BRILLIANT - that works perfectly. Thank you!!

Ok great! Glad to hear that. You’re most welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.