I think you are on the right track with your idea of checking if the right page is being viewed within the callback attached to the upload_size_limit hook.
This code demonstrates changing the upload size if one of the special pages is being viewed, and returning the standard max upload size otherwise:
function wpse239631_change_upload_size( $u_bytes, $p_bytes ) {
// Array of post IDs where the upload size will be changed.
$special_pages = array(
1829, // change to your page
1800, // change to your page, etc
);
// If we're on a special page, change the upload size,
// otherwise, use the default max upload size.
if ( in_array( get_the_ID(), $special_pages ) ) {
return 1024 * 18000;
} else {
return min( $u_bytes, $p_bytes );
}
}
add_filter( 'upload_size_limit', 'wpse239631_change_upload_size', 10, 2 );
Related Posts:
- Upload multiple images to a Woocomerce product
- WordPress automatically adds links to uploaded images
- Is custom behaviour possible when asynchronously uploading?
- How to change upload directory in wp_handle_upload
- Uploading media with the REST API
- Decrease file size upload in Media
- Change the filename format of saved featured images
- How to register images uploaded via FTP in media library?
- Using file_exists to check file in Uploads
- PHP/Manual use of images? – 2 Questions
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Rename image uploads with width in filename
- Modify image while uploading
- Debugging upload problem: What part of WP does actual image-resizing?
- Specified file failed upload test. wp_upload_handle
- How to upload imagick resource to media in wordpress
- Accessing a random image via ajax
- Make WordPress upload directory outside wordpress root with custom url
- Upload images and attachments from frontend form
- Get a Page’s attachments in Gallery order
- Image upload via FTP to wordpress media library
- Adding featured image via PHP
- How to enlarge the media file upload size in wordpress admin
- Using an Image Slider twice on the same page
- File upload, uploads only file name
- Adding a querystring to an image URL when clicking ‘insert into post’?
- How to return output of the new wp gallery block for automatically Link images To Media file
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Custom image upload
- wp_handle_upload – The uploaded file could not be moved to wp-content/uploads/2012/09
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- Memory errors with media upload, WordPress can’t use more than 96M (while there’s 512 available!)
- Validate Uploaded Image using WordPress’ Built-in Functions?
- Get most recent media upload
- Convert all images to PNG on file upload
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- Upload Image in a WordPress page using PHP
- WordPress (3.9.1) MultiSite Permissions. Is chown the answer?
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- how to retrieve uploaded url of zip files
- Add a class to the anchor tag on HTML5 gallery
- PDF file randomly breaks upon upload
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- How to upload a file to a folder named after the user_id via plugin
- Need help with Google drive API [closed]
- How to get next image with this code from same post?
- Can’t upload image using media_sideload_image
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- Enable custom logo upload if logo is not in header
- NGINX rewrite rules for multisite
- Attach previously uploaded image to post – current code has unexpected results
- How do I get around “Sorry, this file type is not permitted for security reasons”?
- WordPress function when file is uploaded, deleted or edited
- Can I get an email notification when media is uploaded to the media library?
- Blob file download problem
- Get title attribute from galleries
- Detecting if parent page has gallery
- WordPress gallery shortag
- Upload multiple files in randomly generated folder using wp_upload_bits
- Can’t upload CSV file to plugin directory using custom upload form in admin panel
- Convert canvas to image and upload image to server
- How to get the filename from file system and create a download link?
- Custom upload folder
- WordPress İmages Upload & Delete Error
- Allow user to Upload image and manipulate it on the frontend
- custom plugin with upload files does not work
- Front end file upload returning wrong attachment url
- Convert all uploaded PNG files to PNG-8 format
- Delete images from media library when user deletes an image from ACF Gallery
- I can’t set image ad fatured programatically
- How can I update WordPress plugins or WordPress itself in all server?
- async upload not working when not logged
- Display metabox galleries on specific page template in admin editor
- WordPress loading all local images from specific directory?
- Trying to generate a CSS file in wordpress uploads folder
- Maximum file Upload
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- Javascript Tab Gallery with Advanced Custom Fields
- Right path for renaming a file in uploads folder
- How to generate customized filtered output for the gallery
- WordPress file upload
- Upload images from one server to an other in wordpress
- media_handle_upload fails with gravity form submitted image
- Using get_the_excerpt in edit-post
- offset and max_num_pages in pagination gallery
- 403 (Forbidden) delete file image in themer folder
- File path for attachments outside of wp-content/uploads
- How to resize an image server-side before upload?
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Dynamic Gallery
- File Upload with Server in safe_mode
- Generate and upload screenshot as featured image for user-submitted post
- Pull latest Youtube Video from json url and make new post
- Upload multiple files via ajax from an HTML file input
- get_post_meta returns on side but it doesn’t return on bottom of admin page
- “Unexpected response from server” error when trying to upload any .mp4 file over 100MB
- Adding a css class to the gallery
- Get a list of folders inside uploads directory
- How can we upload custom page files?
- Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?