I am using Laravel. I am trying to use the Imgix Typesetting endpoints to throw the staff bio overtop of the bio image. When I use the typesetting endpoint alone I get the proper formatted text. But when I encode base64 then append to the Bio image uri, the image looks fine but no text overlay. Does anyone know what I am doing wrong?
Here is the function
public function bioEncode($bio, $align) {
$bioNoSpaces = str_replace(' ', '+', $bio);
$bioTextUrl = base64_encode("http://newsong.imgix.net/~text?txt=" . $bioNoSpaces . "&txtclr=fff&txtsize=20&w=800&txtpad=20&txtfont=avenir-black&txtalign=center");
if($align == 0) {
$newUrl = "http://newsong.imgix.net/staffProfile/cameron-profile-desktop.jpg?fit=crop&crop=top&w=1220&h=500&mark64=" . $bioTextUrl . "&markalign=left,middle&markpad=0";
return $newUrl;
} else {
$newUrl = "http://newsong.imgix.net/staffProfile/cameron-profile-desktop.jpg?fit=crop&crop=top&w=1220&h=500&mark64=" . $bioTextUrl . "&markalign=right,middle&markpad=0";
return $newUrl;
}
}
Here is where I am calling the function
srcset="{{$staff->bioEncode($staff->staff_bio, $staff->desktop_img_text_side)}}"
when entering this into the Imgix sandbox here: https://sandbox.imgix.com/create this url works. I have encoded and decoded the base64 string, and there seems to be nothing wrong.
I am still new to Php, so any help is very much appreciated.
with the help of a friend. I fixed the problem. The trailing equals was messing me up after the base64_encode(). This fixed the problem:
$bioTextUrl = strtr(base64_encode("http://newsong.imgix.net/~text?txt=" . $bioNoSpaces . "&txtclr=fff&txtsize=20&w=800&txtpad=20&txtfont=avenir-black&txtalign=center"), '=', '+');