Manipulating URL passed to Image Script
Since framework 1.3.2, the image function includes a filter, themify_image_script_src, to modify the URL passed to img.php, the Image Script that crops and resizes the images on the fly in Themify themes.
To make use of the filter, follow these steps:
1. Create a file named custom-functions.php in your theme root folder
2. Edit it, and paste the following sample code
<?php
/**
* Modify URL passed to image script
* @param string $src Original image URL
* @return string $src Modified image URL
*/
function custom_theme_themify_image_script_src($src){
// Do something with URL stored in $src here
return $src;
}
add_filter('themify_image_script_src', 'custom_theme_themify_image_script_src');
?>
3. Modify as needed and save the file. If you were editing it locally, upload it by FTP to the theme folder in your server.
Sample Usage
For example, you can use this filter to remove the http:// or https:// scheme
<?php
/**
* Remove URL scheme
* @param string $src Original URL with scheme
* @return string $src Modified URL without scheme
*/
function custom_theme_themify_image_script_src($src){
$replace = array('http://', 'https://', $_SERVER["HTTP_HOST"]);
$src = str_replace($replace, '', $src);
return $src;
}
add_filter('themify_image_script_src', 'custom_theme_themify_image_script_src');
?>