Remove disabled select options on iOS devices from DOM to handle mobile safari issues with disabled select options

if(navigator.userAgent.match(/(iPad|iPhone|iPod touch)/i) 
   && !navigator.userAgent.match(/(iPad|iPhone|iPod touch);.*CPU.*OS 7_\d/i)){
     $('select.your_special_class option[disabled]').remove();

@public #iphone #ipad #js #javasript #target #userAgent #match

Auf diese Weise lassen sich granulare Browserversionen unterscheiden und differenzierte Javasript Aufrufe ausführen.

if/else Kurzschreibweise in JavaScript

/** normale lange Schreibweise **/
  $('select option[value="x"]').remove();
  $('select option[value="x"]').attr('disabled','disabled');

/** wesentlich kürzere Schreibweise **/
omv ? $('select option[value="x"]').remove() : $('select option[value="x"]').attr('disabled','disabled');

@public #javascript #js #if #kurz #jquery

jQuery: how to check if file exists

var base='';
var url='/image_path_to_test.jpg';
var fallback_url='/image_path_exists_for_fallback_image.jpg';

/** Asynchronous!!! **/
  $('#any_DOM_id').append('<img id="my_image" src="'+url+'"/>');
  $('#any_DOM_id').append('<img id="my_image" src="'+fallback_url+'"/>');

@public #jquery #js #javascript #file #exist #test

Hint: $.get() is asynchronous, so this way 'll kill the sequential chronology of your script execution

This GDlib Trick let you stack different transparent png Images to one JPG.


header("Content-Type: image/jpeg");

$image_arr=array('path1.png', 'path2.png', 'path3.png');

$base  = imagecreatetruecolor(913, 500);
$color = imagecolorallocate($base, 255, 255, 255);
imagefill($base, 0, 0, $color);

foreach($image_arr as $key=>$image_val){
    ImageCopy ( $base, $this_layer, 0 , 0 , 0 , 0 , 913 , 500 );

imagejpeg($base,NULL, 85);

@public #gdlib #php #image #transform #stack #jpg

Wozu das Ganze?

Wenn man aus mehreren einzelnen Bildern am Ende ein gesamtes Bild erzeugt, dann ist es besser sich nicht auf die Browser zu verlassen und dass diese die übereinander geschichteten Bilder korrekt darstellen.

Statt JPG als PNG ausgeben

public gdlib php image transform stack png transparent php

This GDlib Trick let you stack different transparent png Images to one transparent png.


$image_arr=array('path1.png', 'path2.png', 'path3.png');
echo gd_gen_image($image_arr);

function gd_gen_image($arr){
    $base  = imagecreatetruecolor(913, 500);
    $color = imagecolorallocatealpha($base, 0, 0, 0, 127);
    imagefill($base, 0, 0, $color);
    imagesavealpha($base, TRUE);

    foreach($arr as $key=>$image_val){
        ImageCopy ( $base, $this_layer, 0 , 0 , 0 , 0 , 913 , 500 );

    // Begin capturing the byte stream
    // END capturing the byte stream
    return "<img src='data:image/png;base64," . base64_encode( $out ) . "' />";


@public #gdlib #php #image #transform #stack #png #transparent

Statt PNG als JPG ausgeben:

How to transfer an Array over URL GET Parameters

/* array_over_get.php */

echo '<img src="process_images.php?arr='.$serial_arr.'" alt="stacked image"/>';

/* process_images.php */

foreach($image_arr as $value){
   /* do anything here 
    * just as an example

Why use of base64 encoding? URLencoding on a string is a waste of space and you only have 4k.

BUT, base64 encode may have +=/ characters, that have to be translated with urlencode mehr Infos:

@public #array #get #parameter #serialize #php



Capsule Servers

Lost connection to server.