How resize this string / change link parameter.

Original file = mydomain.com/wp-content/uploads/2015/01/name-file.jpg

Return to $string now = mydomain.com/wp-content/uploads/2015/01/name-file-300x215.jpg

But, i want this size return to (-90x90) = mydomain.com/wp-content/uploads/2015/01/name-file-90x90.jpg


    //sometime string return this value
    $string = 'mydomain.com/wp-content/uploads/2015/01/name-file-300x215.jpg';

    //and sometime string return like this (original size)
    // $string = 'mydomain.com/wp-content/uploads/2015/01/name-file.jpg';

    //or sometime string return like this (external image link)
    // $string = 'otherdomain.com/wp-content/uploads/2015/01/name-file.jpg';

    //the point now, i want this newstring return like this
    // $string = 'mydomain.com/wp-content/uploads/2015/01/name-file-90x90.jpg';

    if(strpos($tring, 'mydomain.com/wp-content/uploads') !== false ){ //check if this string is internal image link

    $newstring = ''; // i want this $newstring return this value -> mydomain.com/wp-content/uploads/2015/01/name-file-90x90.jpg

    //so i can return this $newstring (new image size 90x90) if string is internal image link
    $return $newstring; 
    } else {
//external image, no need change link parameter
    return $string;

1 Answer 1


If you are using wordpress, this guide might help you - https://developer.wordpress.org/reference/functions/add_image_size/

  • how to implementing that some of php code with above function? Commented Sep 6, 2015 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.