Is there a limit on the size of a WP page?

I have a plugin that generates a gallery of user photos. Currently, it works using img tags pointing to the user photo image. It attaches to the the_content filter.

I’m experimenting with converting to using data URLs. I’m able to generate them with no difficulty, but when I change the code to insert them into the page, requests to that page come back with zero content (i.e. zero length). However, I still get a 200 status code and I don’t see any errors in my logs.

So, I’m wondering if WP has a limit on the size of page it will send. The data URLs add up to around 1MB, so I was wondering if that tripped it over some limit.

  • Gallery generation code
  • User Photo code

Any suggestions?

The salient code is:

$file = trailingslashit($upload_dir['basedir']) . 'userphoto/' . $image_file;
$fileContents = base64_encode(file_get_contents($file));
error_log($fileContents);
$src = "data:image/jpg;base64,$fileContents";
...
...
$img .= '<img src="' . htmlspecialchars($src) . '"';
...
$img .= ' />';

In case it’s relevant, the content is in a page not a post and it would go here: http://nerdnite.com/nerds/

So, that page, but with data URLs instead of image source files.

EDIT

What I do now know is that it’s not the generation of the content string by the filter. I can generate the string (which is of length 1229923), but if I pass a dummy string back, everything works well.

My memory usage is negligible and I’m nowhere near my PHP limit… so it seems to be something to do with WordPress trying to handle that huge string.

1 Answer
1

Some of your user pictures are 30K characters long when encoded. Have you heard of URL length limit? See What is the maximum length of a URL?.

Also I believe there are some limits were put by browser manufacturers in spite of HTML 4-5 specifications does not put any limits on attribute value length (AFAIK).

Leave a Comment