Fit slider width to the image width

Hi designers
I have many images with different width. I want to make a slider with dynamic width that response to the image width. So, every time I change image, slider width also change (like image inside a normal div). How can I make it?