Supersized jQuery plugin; Fit Always per image

Supersized is my go to plugin for fullscreen background images, it just works perfectly. Recently though I had a use case that wasn’t part of the plugin, with Supersized you can either choose to clip an image (and completely fill the browser window) or to “fit always” (so an image is never clipped). I needed an extra level of granularity, I had a slideshow where some of the images needed to be clipped and some couldn’t be clipped.

This one is ok to crop

on’t crop this one

So, in my first epic github adventure, I cloned, branched, and pushed back to my github account with my changes!

You can now use fit_always: true in the images object like so:

  // Functionality
  slide_interval : 3000,
  transition : 1,
  transition_speed : 700,

  slides : [
    {image : '', fit_always: true},
    {image : ''},
    {image : '', fit_always: true},
    {image : '', fit_always: true}

jQuery .load() not working on Internet Explorer

This little snippet was being used as a preloader for some large images on a site I was working on:

// Grab the src attribute
var src1 = $("#home-img1 img").attr('src');

// Add the preloading gif
$("#home-img1").css("background-image","url('/images/ajax-loader.gif')").css("background-position","center center").css("background-repeat", "no-repeat");

// Remove the image from the dom
$("#home-img1 img").remove();

// Load then display the image
$("<img />").attr("src", src1).load(function(){

Which works as you would expect in all browsers, except for our ever redeeming friend internet explorer (ie7-ie8). Internet explorer seems to already treat the image as loaded (even though it’s a new element) and never fires the function in .load(), apparently to Internet Explorer, loading something from the cache doesn’t actually count as loading it. My quick solution to this has been to append a random number to the end of the src1 variable which forces a reload of the image. It’s not a very good solution since I can’t make use of cache, but it fixes the problem.

Thanks Microsoft :-) (assholes)

Stop Skype toolbar from messing with your page

The Skype toolbar likes to look for any phone numbers in your page and replace them with Skype enabled links with some funny formatting. I realise that probably the “correct” thing to do in this situation is leave it alone and let Skype make the changes, but if you’ve got a client with internet explorer and skype installed, they’ve most likely skype toolbar installed, and it’s difficult to tell them it’s their fault when you’re trying to explain why the whole layout has been throw out of whack.

The simple solution: Add this to your <head>


Paypal doesn’t send IPN’s to non standard ports

Just a quick note (that I couldn’t find any documentation about in the Paypal docs), if you set up a test server that listens on something like 8080, and you want paypal to send you instant payment notifications (IPN) to that address, it’s not going to happen. There’s no errors, nothing will come through.

Defining multiple user providers for multiple firewalls in Symfony2

Something I was struggling with and couldn’t find a solid answer anywhere was exactly how you set up your security.yml file to have two seperate gateways for two different types of user. My situation was two different user types that stored different information, I needed separate classes and login routes/method for both. Below is a working example.

            pattern: ^/user
            anonymous: ~
            provider: user_security
                login_path: /user/login
                check_path: /user/login_check
                default_target_path: /user
            pattern: ^/admin
            anonymous: ~
            provider: admin_security
                login_path: /admin/login
                check_path: /admin/login_check
                default_target_path: /admin

            name: user_security
            entity: { class: Vendor\BUNDLE\Entity\UserEntity, property: username }
            name: admin_security
            entity: { class: VENDOR\BUNDLE\Entity\AdminEntity, property: username }

        VENDOR\BUNDLE\Entity\UserEntity: plaintext
        VENDOR\BUNDLE\Entity\AdminEntity: plaintext

The thing that was getting me was was the name parameter under the providers section, in your firewalls section your provider parameter should point to the name of the provider you set under the providers section.