dknife
Well-known member
My site outside of XenForo utilizes the session and content framework of XF, mainly for the media gallery portions, displaying alerts and stuff like recent threads etc. I've been converting my dev site to XF2.1 and very very slowly wrapping my head around the new class structure and trying to utilize as much of the entity and repo system as possible.
After messing around for a couple of hours tonight, I think I've managed to utilize the existing functions correctly to check for the image, check permissions and get the necessary canonical URLs.
This is to retrieve the media info from a media ID
Is this sufficient to work with the abstract data of XF2 and to ensure permissions are followed for the image?
After messing around for a couple of hours tonight, I think I've managed to utilize the existing functions correctly to check for the image, check permissions and get the necessary canonical URLs.
This is to retrieve the media info from a media ID
PHP:
/** @var \XFMG\Entity\MediaItem $mediaItem */
$mediaItem = \XF::em()->find('XFMG:MediaItem', $g['media_id']);
if (!empty($mediaItem) && $mediaItem->canView() === true && $mediaItem->isVisible() === true) {
$image_data = $mediaItem->getStructuredData();
$thumb_url = $image_data['thumbnailUrl'];
$full_url = $image_data['contentUrl'];
}
Is this sufficient to work with the abstract data of XF2 and to ensure permissions are followed for the image?