Browse Source

Ajout dimensions img et possibilité d'utiliser des svg

master v3.0.3
Graphie 5 months ago
parent
commit
7856b7012e
  1. 2
      paquet.xml
  2. 2
      socialtags.js.html
  3. 21
      socialtags.js_fonctions.php

2
paquet.xml

@ -1,7 +1,7 @@
<paquet
prefix="socialtags"
categorie="communication"
version="3.0.2"
version="3.0.3"
etat="stable"
compatibilite="[3.2.0;4.1.*]"
logo="prive/themes/spip/images/socialtags-32.png"

2
socialtags.js.html

@ -33,7 +33,7 @@
[(#CONFIG{socialtags/ifreferer}|?{"
if (Cookies.get('social_'+this.a)!=1) return;"})]
$('<a rel="nofollow"[ (#CONFIG{socialtags/wopen, 'non'}|=={oui}?{#GET{popup}})]><img class="socialtags-hovers" src="'+ this.i +'" alt="'+this.a+'"\/><\/a>')
$('<a rel="nofollow"[ (#CONFIG{socialtags/wopen, 'non'}|=={oui}?{#GET{popup}})]><img class="socialtags-hovers" src="'+ this.i +'" width="'+ this.w +'" height="'+ this.h +'" alt="'+this.a+'"\/><\/a>')
.attr('href',
this.u
.replace(/%u/g, esc(url))

21
socialtags.js_fonctions.php

@ -9,7 +9,7 @@ function socialtags_json($cfg) {
return '[]';
$json = array();
include_spip('socialtags_fonctions');
foreach (socialtags_liste() as $service)
@ -18,8 +18,23 @@ function socialtags_json($cfg) {
$u = _q($service['url']);
$d = isset($service['descriptif']) ? _q($service['descriptif']) : $t;
$u_site = _q($GLOBALS['meta']['adresse_site']);
$i = _q('data:image/png;base64,'.base64_encode(file_get_contents(find_in_path('images/'.$a.'.png'))));
$json[] = "{ a: '{$a}', n: {$t}, i: {$i}, u: {$u}, u_site: {$u_site}}";
$png = find_in_path('images/'.$a.'.png');
$svg = find_in_path('images/'.$a.'.svg');
if ( $svg ) {
$xml = simplexml_load_file($svg);
$attr = $xml->attributes();
$w = intval($attr->width);
$h = intval($attr->height);
$i = _q('data:image/svg+xml;base64,'.base64_encode(file_get_contents($svg)));
}
else if ( $png ) {
$icon = file_get_contents($png);
$img = imagecreatefromstring($icon);
$w = intval(imagesx($img));
$h = intval(imagesy($img));
$i = _q('data:image/png;base64,'.base64_encode($icon));
}
$json[] = "{ a: '{$a}', n: {$t}, i: {$i}, w: {$w}, h: {$h}, u: {$u}, u_site: {$u_site}}";
}
return "[\n" . join(",\n", $json) . "\n]";

Loading…
Cancel
Save