【问题标题】:drupal 8 file upload path on node_presave hooknode_presave钩子上的drupal 8文件上传路径
【发布时间】:2017-07-11 07:36:43
【问题描述】:

我需要在node_presave钩子上找到文件上传路径

   function hooks_example_node_presave(EntityInterface $node) {

var_dump($node->field_image_upload->getValue()); exit;

    }

这是我尝试过的。帮助将不胜感激。 谢谢 拉杰

【问题讨论】:

    标签: drupal drupal-8 drupal-hooks


    【解决方案1】:

    我找到了解决方案。下面会得到上传的文件url。

    $node->field_image_upload->entity->url()
    

    【讨论】:

      【解决方案2】:

      你需要写这个

      function hooks_example_node_presave(Drupal\Core\Entity\EntityInterface $entity) {
      
       $image = $entity->field_seedit_thumbnail_image->getValue();
      
       $fid = !empty($image[0]['target_id']) ? $image[0]['target_id'] : '';
      
      }
      

      【讨论】:

        猜你喜欢
        • 2018-10-19
        • 1970-01-01
        • 1970-01-01
        • 2021-06-07
        • 1970-01-01
        • 1970-01-01
        • 2015-02-05
        • 2011-04-08
        • 2014-01-19
        相关资源
        最近更新 更多