0

I have scoured the web for plugins and articles to help me solve something that seems pretty basic, but couldn't find anything.

I want a way to create custom versions, particularly sizes, of an image on a per-image basis.

I know I can register a specific size of image and WP will create it for every image that is uploaded.

But what I want is to be able to create a scaled version of an existing image from the media library UI.

For example, let's say I upload image A. WP creates a version by default that is 600px wide and I use it at that size throughout the website.

But then I have a call-to-action box in an article where I want to display the image, but with a width of 175px.

So, I want to create a version of that image at the 175px width, as well as a retina 2x 350px wide.

When I add the image to the box, I want WP to output a srcset that includes those two additional sizes so that the browser can pick whichever image it thinks is best for the situation.

I don't want to specify those 175px and 350px as additional image sizes for ALL images, because I won't need it for most of them.

This seems like a pretty common use-case to me, but despite that I couldn't find anything.

Perhaps I am using the wrong keywords and I hope someone here can point me in the right direction.

-1

so you can do that in 2 different ways 1. modify directly on template-parts/content-single.php
2. you can plug it using the

add_action(pre_get_post,func_with_your_staff ) 

inside this

    function func_with_your_staff( $query ) {
        global $wp ; 
     if ( $query->is_single() && empty($query->post_type) $query->set('post_type', 'wherever_is_type'); // perhaps you have a custom_post_type 
    ?> and then you can add your extra staff <img src"" class="big-img"> <?
} 
  1. you can use jQuery(myImg).css('width','600px')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.