Ah. I did that instinctively.
True the link I get is https://pbs.twimg.com/media/Fg5zVLfXoAEkH66?format=jpg&name=medium
but you can just remove everything after ? and append whats inside format= as the file extension to render for twitter links that match that regex