I need PressThis to replace part of image urls that contain certain text.
Example:
A url containing photo420_sz95x95.jpg would be changed to photo420_szfullxfull.jpg via script detecting sz95x95 and replacing it with szfullxfull.
From what I can see, this would be a mod to the press-this.php file in the wp-admin folder and should only involve a couple quick lines of conditional code.
All of this would need to go down before the images PressThis pulls are loaded into the 'Add Photo' box so that when I click insert, the szfullxfull version will be what Wordpress works with.
Christianto answers:
Hi,
If you need image with 95x95 string and other image different string for example 60x60.
Put this code on press-this.php on line 58 before <strong><em>// set the post_content and status</em></strong>
$content = preg_replace('/_sz(\d+)x(\d+)/i','_szfullxfull',$content);
// set the post_content and status
edit - replace strip the underscore :D
Christianto comments:
Sorry I thought you want to change if the content being saved..
<blockquote>All of this would need to go down before the images PressThis pulls are loaded into the 'Add Photo' box so that when I click insert, the szfullxfull version will be what Wordpress works with.</blockquote>
Did you means if user click on 'insert an image' icon all image from the page you want to reblog, all images on the blog that contain 'sz95x95' string on the target site will be replace with 'szfullxfull'?
So all image show in the add Photos is image with szfullxfull?
Christianto comments:
Put this code on your press-this.php on line 216..
before <strong><em>// if no http in url</em></strong>
$src = preg_replace('/_sz(\d+)x(\d+)/i','_szfullxfull',$src);
// if no http in url
if you only need 95x95 just change the pattern from '/_sz(\d+)x(\d+)/i' to '/_sz95x95/i'
Let me know if this work on your site...
siddalee comments:
<blockquote>Put this code on your press-this.php on line 216..
before // if no http in url
$src = preg_replace('/_sz(\d+)x(\d+)/i','_szfullxfull',$src);
// if no http in url</blockquote>
Perfect! Many thanks to both of you!
Jerson Baguio answers:
Try to test on this if it will work
//$photo_url is the variable to hold your image url or filename
$newphoto_url = str_replace ( "sz95x95" ,"szfullxfull" , $photo_url);