View Convert in base 64 file
<?php | |
/** | |
* @param string $pathToImg | |
* @return string | |
*/ | |
function toBase64(string $pathToFile): string | |
{ | |
$type = pathinfo($pathToFile, PATHINFO_EXTENSION); | |
$data = file_get_contents($pathToFile); | |
return 'data:image/' . $type . ';base64,' . base64_encode($data); |
View wordpress picture only
/** | |
* @param WP_Post $post | |
* @return string|null | |
*/ | |
function getPictureTyre(\WP_Post $post): ?string | |
{ | |
$result = null; | |
$pathToImg = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'Large size')[0]; | |
if ($pathToImg !== null) { | |
$result = '<img src="' . $pathToImg . '" class="tyre-post-thumbnail" >'; |
View gist:d30953da3e3f54a75461e2bc32070961
function removeDuplicates(myArr, prop) { | |
return myArr.filter((obj, pos, arr) => { | |
return arr.map(mapObj => mapObj[prop]).indexOf(obj[prop]) === pos; | |
}); | |
} |
View gist:a2bef084b19ba17d29159c9a3f45c186
/** | |
* @param string $url | |
* @return string|string[] | |
*/ | |
function force_relative_url(string $url) | |
{ | |
return str_replace(get_site_url(), '', $url); | |
} | |
/** |
View gist:4268920ea2f36a43f5008b36cf5dbc40
function isIE() { | |
var value = false; | |
if (window.navigator.userAgent.indexOf('Trident/') > 0) { | |
value = true; | |
} | |
return value; | |
} | |
if (isIE() !== true){ | |
$('.ie-browser-connected').remove(); |