This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Get local oembed thumbnail path [solved + example]

I am currently trying to patch a module so that you can use the local oembed thumbnail to display as a preview.

Currently the direct url to the youtube thumbnail is used but that is, of course, not allowed by DSGVO/GDPR cancer.

My idea was to use the hook and load the thumbnail there. But OEmbed::getLocalThumbnailUri is a protected function.

Any ideas hints or tips? Any contrib doing this where i could read some code? Thank you.

function hook_preprocess_media_oembed_iframe(array &$variables) {

Is there a Media acces control mechanism in Drupal?

I am using hook_node_access_records() , and hook_node_grants() in a custom module for node acces control and it Works perfectly

I am wondering if there would be something similar for media entities??

Thanks in advance for your advices.

 

Struggling with dependency injection

I am still struggling to understand how to use dependecy injection correctly.

(This is all from the contributed extension Notify)

It has a a service class named "Notify".

In it, I am doing a lot of direct calls to global service containers. Example:

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple();

This works (i.e. it gets the nodes), but I am getting warned by PHPstan:

How does a path become content in Drupal 7? (aka auditing content effectively)

Heya! I'm working on a project for a client who is using Drupal 7. Among other things, we want to perform an audit of the content currently stored in their Drupal instance. Specifically, I want to create a list of every page / link on the site and any related files / downloads that Drupal is managing for them. 

Looking at the APIs, I honestly have no idea where to start here. I am also digging around the database and, while I see the nodes and various field_ tables that seem to have the content stored in them, I see no obvious way they're connected. 

What's the correct way to set a field value in views_pre_render?

Here's my code.

I'm trying to populate a custom text field that has a default value with a new value thus:

function mytheme_views_pre_render(Drupal\views\ViewExecutable $view) {
if ($view->id() == "contacts" && $view->current_display == 'block_7') {
foreach ($view->result as $row) {
$cid = $row->_entity->id->value;
$cs = lgf_checksum_get($cid);
if ($cs) {
$row->_entity->nothing->setValue($cs);
}
}
}
}

It's throwing this error 

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions