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 manually fix the WordPress gallery code using PHP in functions.php?
- How to change upload directory in wp_handle_upload
- 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”?
- Way to add captions to gallery images by code
- Custom gallery in wp3.5
- Change WordPress Upload Folder using wp handle upload
- How do I Import / Upload Files with jQuery AJAX?
- 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
- zip unzip attachments in wordpress
- Get title attribute from galleries
- Detecting if parent page has gallery
- WordPress gallery shortag
- Timthumb.php image gallery not working on Multisite WordPress
- Upload multiple files in randomly generated folder using wp_upload_bits
- Change default gallery images – Currently they are displaying full size imagese
- Can’t upload CSV file to plugin directory using custom upload form in admin panel
- WordPress upload file size error even after raising php limits
- Get uploaded image and attach it to the new post
- Get featured image with custom size outside WordPress
- Why is my max_upload_filesize being limited to 2M? [duplicate]
- Images Uploaded saving onto older/previous year folders
- Convert canvas to image and upload image to server
- How to get the filename from file system and create a download link?
- Get URL of Featured Image After wp_insert_post()
- 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
- How to Make Thumbnail of Post Stay Animated
- Front end file upload returning wrong attachment url
- Adding a ‘style=’ bit to image_send_to_editor output
- Convert all uploaded PNG files to PNG-8 format
- How to decrease the max file upload size without using php.ini or htaccess?
- Auto create Nextgen Gallery on post creation [closed]
- Some problems in custom widget
- Checking page before applying image restrictions while uploading
- remove specificly the last tag in all posts
- Change image data durgin upload
- Hook on file upload
- Delete images from media library when user deletes an image from ACF Gallery
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- I can’t set image ad fatured programatically
- How can I update WordPress plugins or WordPress itself in all server?
- Create shortcode for metabox gallery
- 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
- ACF Gallery field images donwload
- Maximum file Upload
- add custom link to gallery images
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- Change upload URL by mime type
- 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
- I want url from a file in media using title file
- WordPress file upload
- Upload images from one server to an other in wordpress
- Crop an image after upload on custom account page
- media_handle_upload fails with gravity form submitted image
- Restrict File Type Uploads by User on Wordress via functions.php
- Using get_the_excerpt in edit-post
- wp_delete_attachment not working with multiple values
- Renaming “Expand Details” within “Add Media”
- offset and max_num_pages in pagination gallery
- Using catch_that_image() for galleries?
- Save the outputted image into the Media Library, with a different filename and extension
- 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)
- Creating image gallery in wordpress
- Dynamic Gallery
- Name Input from widget displays Sidebar name instead of saved data
- Gallery requires a featured image but does not show it in posts/pages
- Can’t upload files
- File Upload with Server in safe_mode
- Edit Image/Image Details – Replace button missing
- Correct Syntax for uploading files to custom directory in WordPress
- How to automatically convert images to WebP on WordPress?
- Generate and upload screenshot as featured image for user-submitted post
- Pull latest Youtube Video from json url and make new post
- WordPress directories not writable after PHP version upgrade
- 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
- Changing upload directory temporarily
- How can we upload custom page files?
- Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?
- How to save WordPress post and attachment images from front end using media library?
- Unable to upload media to WordPress