Znalazłem gotową bibliotekę do tego
https://github.com/salesagility/SuiteCRM/tr...dules/SugarFeed
Zależy mi na tym, żeby po wklejeniu linku z youtube'a i po kliknięciu 'send' na tablicy wyświetlała się miniatura tego linku, podobnie jeżeli chodzi o zdjęcie. Czytałem na tej stronie że w tym kodzie jest to już zawarte ale u mnie to nie działa. Wkleja linki bez miniaturek, niezależnie od tego czy to link do yt czy zdjęcie.
Macie jakiś pomysł ? Albo widzicie błąd w kodzie? Nie za bardzo poruszam się jeszcze w php.
Żebyście nie musieli grzebać w tej bibliotece tutaj są 2 kody odpowiedzialne za to:
Kod do miniaturki z yt
require_once('modules/SugarFeed/linkHandlers/Link.php'); class FeedLinkHandlerYoutube extends FeedLinkHandlerLink { function getDisplay(&$data) { return '<div style="padding-left:10px"><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/' . $data['LINK_URL'] . '&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="wmode" value="opaque" /><embed src="http://www.youtube.com/v/' . $data['LINK_URL'] . '&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" wmode="opaque" width="425" height="344"></embed></object></div>'; } function handleInput($feed, $link_type, $link_url) { $feed->link_type = $link_type; $feed->link_url = $match[1]; } }
Kod wyświetlający zdjęcie.
require_once('modules/SugarFeed/linkHandlers/Link.php'); class FeedLinkHandlerImage extends FeedLinkHandlerLink { function getDisplay(&$data) { if ( $imageData['width'] != 0 ) { $image_style = 'width: '.$imageData['width'].'px; height: '.$imageData['height'].'px; border: 0px;'; } else { // Unknown width/height // Set it to a max width of 425 px, and include a tweak so that IE 6 can actually handle it. $image_style = 'width: expression(this.scrollWidth > 425 ? \'425px\':\'auto\'); max-width: 425px;'; } return '<div style="padding-left:10px"><img src="'. $imageData['url']. '" style="'.$image_style.'"></div>'; } function handleInput($feed, $link_type, $link_url) { parent::handleInput($feed, $link_type, $link_url); // The FeedLinkHandlerLink class will help sort this url out for us $link_url = $feed->link_url; // The image didn't pull down properly, could be a link and allow_url_fopen could be disabled $imageData[0] = 0; $imageData[1] = 0; } else { // This is a large image, we need to set some specific width/height properties so that the browser can scale it. } } $feed->link_url = base64_encode(serialize(array('url'=>$link_url,'width'=>$imageData[0],'height'=>$imageData[1]))); } }