0

I have videos on my site component HWDmedia share. They haven't schema.org integration and trying add markup to videos. For videoobject have 4 types and i add 3 of them (name,description and date) but have problems with thumbnails. As video from youtube loading with iframe thumbnails also loading in iframe, but it also adding to database. I try to add code from joomla documentation to get that url

<?php
// Get a db connection.
$db = JFactory::getDbo();
 // Create a new query object.
$query = $db->getQuery(true);

$query
    ->select($db->quoteName(array('id', 'thumbnail')))
    ->from($db->quoteName('ojn5g_hwdms_media'));

$db->setQuery($query);
$row = $db->loadRow();
print_r($row);
?>

But in result i get

stdClass Object ( [id] => 28 [thumbnail] => )
  • On a side note, please replace ojn5g_ with #__, which is the generic Joomla database table prefix. As for the thumbnail, have you checked in PhpMyAdmin that the value actually exists? – Lodder Mar 5 '16 at 17:39
  • I use this code <?php // Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); $query ->select($db->quoteName(array('thumbnail'))) ->from($db->quoteName('ojn5g_hwdms_media')) ->where($db->quoteName('id') . ' LIKE '. $db->quote(46)); $db->setQuery($query); $row = $db->loadRow(); print_r($row); ?> and get result Array ( [0] => https://i.ytimg.com/vi/SXTOwG1XhSM/maxresdefault.jpg ) that correct but i need get this thumbnails from database and check if thumbnail of this video or no. How can i do it? – Murad Mar 6 '16 at 7:16
1

I already solve my problem Here is code

 <?php
/// Get a db connection.
$db = JFactory::getDbo();
 // Create a new query object.
$query = $db->getQuery(true);
$query
    ->select($db->quoteName(array('id','thumbnail')))
    ->from($db->quoteName('#__hwdms_media'));

$db->setQuery($query);
$results = $db->loadObjectList();
$thisitem = $this->item->id; // HWD media share this item id 
$objectoarr = json_decode(json_encode($results),true); // Convert stdClass object to array

foreach ($objectoarr as $thumbnail) {
    if ($thumbnail['id'] == $this->item->id) {
        // Do something with $thumbnail['id'] and $thumbnail['thumbnail']
      $medthumb = $thumbnail['thumbnail'];
      echo "<meta itemprop=\"thumbnailUrl\" content=\"$medthumb\"/>";// 
    }
}

?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.