Apparently, your mod is storing the complete path to the image as a string. That leaves you little alternative but to do a search and replace on the string:
$img = get_theme_mod('image-1');
if (!empty ($img)) {
$img = preg_replace ('.(jpg|jpeg|png|gif)$','-525x350$0');
if (!file_exists($img)) $img = get_template_directory_uri().'/images/default.jpg';
}
else if (!file_exists($img)) $img = get_template_directory_uri().'/images/default.jpg';
In words. Get the mod. If it exists search $img
for the occurence of jpg|jpeg|png|gif
at the end of the string and then prepend it with the image size, eg ...image-525x350.jpg
. If that file does not exist, use the default. If there is no mod, also use the default.
Related Posts:
- Is having multiple theme customizers for different pages possible?
- One button to change all settings in theme customizer?
- Design view breaking on Pages
- Passing array in add_option()
- Customizer: active_callback and sanitize_callback incompatibility?
- WordPress Customizer Default Image
- Use Custiomizer to setup meta theme color tag
- How to store the_post_thumbnail() value in a variable
- Need help setting default setting value for radio button in theme customizer
- How to export/import theme customizer settings?
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Permanently remove first image from posts
- reason of splitting theme files to multiple files
- How to get the registered sidebar’s name by its id?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Dynamically change feature image in customiser
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Dynamically loaded Theme components based on Customizer Settings values : changes not appearing in Customizer preview – (Workaround found)
- Use different javascript files for each page on website
- Show different Customizer Settings on Page-Tamplates
- Widgets not showing in my custom theme
- How do themes render caption texts in extended markup (e.g. “wp-caption” paragraphs)
- Changing the template hierarchy
- Can’t load WP function into external function
- Set WordPress Default Template
- How do I get current page ID in WordPress customizer file?
- Customizer: Output default value in Customizer CSS
- WordPress does not load page.php, return 404.php
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Skt full width basic slideshow problem
- How do I link a button I created in theme customizer to a function?
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- What does this mean in wordpress? Easy question
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Reason to add a name of the theme like (‘menu-1’ => __( ‘Primary’, ‘twentynineteen’ ),) in PHP?
- Separation of presentation and code – WordPress
- Why in my theme I can’t see all the statics content under the posts?
- get_template_directory adding FTP root folders in urls
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- How to add the sidebar to all the pages except the home page? [closed]
- Header not properly displaying on archive.php
- Save Custom CSS file in the upload folder dynamically?
- Warning: printf(): Too few arguments in helpers.php file
- home.php show blog posts as grid view
- How to Update an old theme for the latest wordpress version
- get_comments_number() returns 0
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- Why in this WordPress theme I can’t see the Main Menu?
- How can I assign separate stylesheets to different pages?
- Need advice on theme customizer and child themes
- How to make sure relative URL works when site is not on root domain?
- Commas in Tag Cloud
- Displaying images outside the content
- WordPress redirects page query parameter in URL
- Getting text from custom field from customizer
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Not able to remove caption shortcode from the content
- When I click for the redirect link it is showing the content of index.php instead of single_assignment_page.php
- How to use data URL in WordPress?
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Unable to retrieve get_author_posts_url
- Display post date also if the date it’s the same for each post
- WordPress child theme, creating a custom php template page
- Menu to the right of screen on desktop using Bootstrap 4
- Customizer: How to Sanitize a Decimal Number Range
- Get the image title and alt from custom query
- How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?
- Rotating Header Images
- Create a custom theme-specific page, invisible in the admin-panel?
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Save the outputted image into the Media Library, with a different filename and extension
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Image not displayed
- Gallery requires a featured image but does not show it in posts/pages
- How to add button to top of theme customizer?
- Predefine Magazine Style Layouts
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- Using Featured Image as Hero Background in Word Press
- Font Awesome Icons as squares [closed]
- Capture the Selected Radio Button Value between two files in wordpress theme
- Gulp dev environment set up for WordPress theme development
- How do I create a single.php file as the default template for single posts in the twentytwentythree theme?
- Show the terms of the hierarchical taxonomy
- What is considered good practice for registering menu locations?
- The theme doesn’t load css and JS files doesn’t load in functions.php
- Change default gallery images – Currently they are displaying full size imagese
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- get_page_template_slug returns incorrect path
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- How to set Post meta-box defaults based on the choices made by user in Customizer?
- WordPress and PHP Version Upgrade issue [closed]
- I’m unable to call img path using single quotes in an array?
- Custom post type permalinks do not appear using the link functions
- Creating black and white copy of an image [closed]