Grow your CSS skills. Land your dream job.

php encode images

  • # June 3, 2013 at 5:22 am

    Hey Guys, I have one question for you, maybe it sounds stupid but anyway.

    Is there away to encode the featured images of wordpress posts? I mean I can store in a php var the url of a Featured image of a posts, but how can I encode this image. I’ve tried to using this:

    < ?php
    $img_url = the Featured image url;
    $encode_image = base64_encode($image_url);
    ?>

    and them I use this:

    < ?php the_title(); ?>

    # June 3, 2013 at 11:03 am

    You don’t need to encode the image URL; you need to encode the image itself (the file). Read about [`file_get_contents`](http://php.net/file_get_contents).

    As a side note, however, this is Not A Great Idea unless the images are *tiny* (icon-sized, and even then it depends). Doing this with normal-sized images would make your page insanely heavy, and -since the images are inline in the markup- would block page rendering until they were done being downloaded.

    # June 4, 2013 at 8:26 am

    @traq, thank you for your time, I’m not using this on a live project I’m just playing around. But thank you for your in site on this. Cheers.

    # June 4, 2013 at 7:14 pm

    Well, live project or not, heavy is heavy. As I said, it *does* have its applications. Did you get it figured out?

    # July 1, 2013 at 6:41 am

    yes thank you so much. Cheers

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".