My opinion is that long (or numerous) code blocks (and/or images) should be discouraged while asking and editing questions, in much the same way duplicate questions are discouraged.
If the user continues to post the question with ridiculously long/numerous code blocks or images, despite the warning, then they should be hidden and replaced with "show/hide" links that, of course, shows or hides each block in its entirety (or maybe all blocks with just one link if there are too many). It would also be nice if these links were available on anything longer than maybe 3 lines, or maybe even every block, but not automatically collapsed.
Not only will this make it easier for those reading the question to show only the information they need to come up with an answer, but it also provides further discouragement to the user who asked the question, because now the people who might usually answer are less likely to spend time on a bloated question. They see that certain parts are already collapsed, which they will soon learn is usually bad news.
I mean, look at this mess:
How to handle custom Java exception in Flex app
This is just awful. Now, maybe all of that is necessary, I don't know (I doubt it). But if those were all collapsed, you could take one look and know without scrolling that there is probably too much information being presented here.