diff --git a/VERSIONS_HOTLINE/128703 b/VERSIONS_HOTLINE/128703
new file mode 100644
index 0000000000000000000000000000000000000000..44b824bc195c058b9406ad907a0ead7e3cc17f62
--- /dev/null
+++ b/VERSIONS_HOTLINE/128703
@@ -0,0 +1 @@
+ - ticket #128703 : Magasin de thèmes : correction des liens d'emprunt de ressources PNB.
\ No newline at end of file
diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php
index 54342932a71f27a85c609e022aae1c084fe1dfd7..0d81295f70841e7494dfacf1cbff6e22ca06f058 100644
--- a/application/modules/opac/controllers/NoticeajaxController.php
+++ b/application/modules/opac/controllers/NoticeajaxController.php
@@ -623,22 +623,22 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
              'clef_oeuvre' => $this->notice->getClefOeuvre(),
              'type_doc' => $this->notice->getFamilleId()];
 
-    $helper = $this->_helper->getHelper('HTMLAjaxResponse');
-
     if ( !$data = Class_WebService_AllServices::runServiceAfi(6, $args))
-      return $helper->direct('');
+      return $this->_helper->ajax();
 
     if ( !isset($data['player']) || (!$html = $data['player']))
-      return $helper->direct('');
+      return $this->_helper->ajax();
 
-    $source = isset($data['source']) ? $data['source'] : $this->_('source inconnue');
+    return $this->_helper->ajax(function() use ($html, $data)
+                                {
+                                  $source = isset($data['source'])
+                                    ? $data['source']
+                                    : $this->_('source inconnue');
 
-    preg_match('/src="([^"]+)"/', $html, $match);
+                                  preg_match('/src="([^"]+)"/', $html, $match);
 
-    if ( !$url = $match[1])
-      return $helper->direct('');
-
-    $helper->htmlAjaxResponseWithScript($this->view->renderEmbed($data['source'], $url));
+                                  return $this->view->renderEmbed($source, $match[1]);
+                                });
   }
 
 
@@ -707,10 +707,11 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
     if (empty($html))
       $html = $this->view->renderEmptyMedia();
 
-    $helper = $this->_helper->getHelper('HTMLAjaxResponse');
-    return empty($html)
-      ? $helper->direct('')
-      : $helper->htmlAjaxResponseWithScript($this->view->grid($html));
+    return $this->_helper->ajax(function() use ($html)
+                                {
+                                  if ($html)
+                                    return $this->view->grid($html);
+                                });
   }
 
 
diff --git a/library/ZendAfi/Controller/Action/Helper/Ajax.php b/library/ZendAfi/Controller/Action/Helper/Ajax.php
index 1d6063891e8bbec8bcee853441c62a73446bc059..96f761706b732fee5a44bc04231df89e004acfed 100644
--- a/library/ZendAfi/Controller/Action/Helper/Ajax.php
+++ b/library/ZendAfi/Controller/Action/Helper/Ajax.php
@@ -21,7 +21,9 @@
 
 
 class ZendAfi_Controller_Action_Helper_Ajax extends Zend_Controller_Action_Helper_Abstract {
-  public function direct($callback) {
+  public function direct($callback = null) {
+    if (!$callback)
+      $callback = function() {};
     session_write_close();
     $view = $this->getActionController()->view;
     $viewRenderer = $this->getActionController()->getHelper('ViewRenderer');
diff --git a/library/ZendAfi/Controller/Action/Helper/HTMLAjaxResponse.php b/library/ZendAfi/Controller/Action/Helper/HTMLAjaxResponse.php
index 4b7c1d5ad1058d14c0ed1d8a7ddbcc372c15ccab..ba111ec3c51d35c5929cda8a2ade6f0f5c0ff4ea 100644
--- a/library/ZendAfi/Controller/Action/Helper/HTMLAjaxResponse.php
+++ b/library/ZendAfi/Controller/Action/Helper/HTMLAjaxResponse.php
@@ -35,7 +35,7 @@ class ZendAfi_Controller_Action_Helper_HTMLAjaxResponse
   public function htmlAjaxResponseWithScript($content) {
     Class_ScriptLoader::getInstance()
       ->addAdminScript('onload_utils')
-      ->addJQueryReady('setupAnchorsTarget();');
+      ->addJQueryReady('initializePopups();setupAnchorsTarget();');
 
     $this->direct(Class_ScriptLoader::getInstance()->html() . $content);
   }
diff --git a/library/templates/Intonation/View/Ajax.php b/library/templates/Intonation/View/Ajax.php
index 46e2e86f752eb551deaf519a9d71d0ab0a3a27d9..08fa740deb93d211f56d4615e01c110e58ad4212 100644
--- a/library/templates/Intonation/View/Ajax.php
+++ b/library/templates/Intonation/View/Ajax.php
@@ -33,8 +33,7 @@ class Intonation_View_Ajax extends Intonation_View_Opac {
 
   public function render() {
     Class_ScriptLoader::getInstance()
-      ->addJQueryReady('initializePopups();')
-      ->addJQueryReady('setupAnchorsTarget();');
+      ->addJQueryReady('initializePopups();setupAnchorsTarget();');
 
     return $this->_body . Class_ScriptLoader::getInstance()->html();
   }
diff --git a/library/templates/Intonation/View/RenderEmbed.php b/library/templates/Intonation/View/RenderEmbed.php
index 8a54a89f99e01cfcf85966698807b236a5a48c99..5f22ea4361c724389e6f8e06204fb3261cd75530 100644
--- a/library/templates/Intonation/View/RenderEmbed.php
+++ b/library/templates/Intonation/View/RenderEmbed.php
@@ -22,6 +22,9 @@
 
 class Intonation_View_RenderEmbed extends ZendAfi_View_Helper_BaseHelper {
   public function renderEmbed($source, $url) {
+    if (!$url)
+      return '';
+
     $html = $this->_div(['class' => 'embed-responsive embed-responsive-16by9'],
                         $this->_tag('iframe',
                                     '',
diff --git a/library/templates/Intonation/View/RenderRecord/Items.php b/library/templates/Intonation/View/RenderRecord/Items.php
index 15214d1ec2c8e681311c79e960c6d176196efaed..922ac20aa35ccad1caa99b002cc3f57c2b81b0b8 100644
--- a/library/templates/Intonation/View/RenderRecord/Items.php
+++ b/library/templates/Intonation/View/RenderRecord/Items.php
@@ -21,7 +21,6 @@
 
 
 class Intonation_View_RenderRecord_Items extends Intonation_View_RenderRecord_Abstract {
-
   public function RenderRecord_Items($record) {
     return $this->_renderCurrentSection($record, 'document_items');
   }
diff --git a/tests/scenarios/Templates/TemplateDigitalResourcesTest.php b/tests/scenarios/Templates/TemplateDigitalResourcesTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..5d4c573396f2378eb1257165c66e0ba9fab14fad
--- /dev/null
+++ b/tests/scenarios/Templates/TemplateDigitalResourcesTest.php
@@ -0,0 +1,134 @@
+<?php
+/**
+ * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * BOKEH is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * BOKEH is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with BOKEH; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+
+class TemplateDigitalResourcesDispatchTest extends AbstractControllerTestCase {
+  protected $_storm_default_to_volatile = true;
+
+
+  public function setUp() {
+    parent::setUp();
+
+    $this->_buildTemplateProfil(['id' => 9,
+                                 'template' => 'MUSCLE']);
+
+    $this->fixture('Class_Notice',
+                   ['id' => 123,
+                    'type_doc' => Class_TypeDoc::LIVRE_NUM]);
+
+    $this->fixture('Class_Exemplaire',
+                   ['id' => 34,
+                    'id_origine' => 8,
+                    'id_notice' => 123]);
+
+    $this->fixture('Class_Album',
+                   ['id' => 8,
+                    'titre' => 'old book',
+                    'type_doc_id' => Class_TypeDoc::LIVRE_NUM]);
+
+    $this->dispatch('noticeajax/digital-resources/id_notice/123');
+  }
+
+
+  /** @test */
+  public function bookletShouldBeLoadedWithAlbumTypeLivreNumerique() {
+    $this->assertXPathContentContains('//script', '_load_in_scriptsRoot');
+  }
+
+
+  /** @test */
+  public function setupAnchorsTargetShouldBeInScript() {
+    $this->assertXPathContentContains('//script', 'setupAnchorsTarget();');
+  }
+
+
+  /** @test */
+  public function initializePopupsShouldBeInScript() {
+    $this->assertXPathContentContains('//script', 'initializePopups();');
+  }
+}
+
+
+
+
+class TemplateDigitalResourcesMediaAndTrailerDispatchTest extends AbstractControllerTestCase {
+
+  protected $_storm_default_to_volatile = true;
+
+
+  public function setUp() {
+    parent::setUp();
+
+
+    $this->_buildTemplateProfil(['id' => 5,
+                                 'template' => 'CHILI']);
+
+    $this->fixture('Class_Notice',
+                   ['id' => 34,
+                    'titre_principal' => 'Psycho',
+                   ]);
+
+    Class_CosmoVar::set('url_services', 'https://cache-server.org');
+
+    $mock = $this
+      ->mock()
+      ->whenCalled('open_url')
+      ->answers(json_encode(['source' => 'testing',
+                             'player' => '<iframe src="https://www.super-trailers.org/?media=18397590" style="width:500px; height:400px" frameborder="0"></iframe>']));
+
+    Class_WebService_AllServices::setHttpClient($mock);
+  }
+
+
+  /** @test */
+  public function noticeajaxTrailershouldDisplayTrailer() {
+    $this->dispatch('/noticeajax/trailer/id/34');
+    $this->assertXPath('//div[contains(@class, "embed-responsive")]//iframe[@src= "https://www.super-trailers.org/?media=18397590"][@class="embed-responsive-item"]', $this->_response->getBody());
+  }
+
+
+  /** @test */
+  public function noticeajaxTrailershouldContainsInitializePopup() {
+    $this->dispatch('/noticeajax/trailer/id/34');
+    $this->assertXPathContentContains('//script', 'initializePopups();');
+  }
+
+
+  /** @test */
+  public function noticeajaxMediaDisplayTrailer() {
+    $this->dispatch('/noticeajax/media/id/34');
+    $this->assertXPath('//div[contains(@class, "embed-responsive")]//iframe[@src= "https://www.super-trailers.org/?media=18397590"][@class="embed-responsive-item"]');
+  }
+
+
+  /** @test */
+  public function shouldRenderEditTrailer() {
+    $this->dispatch('/noticeajax/media/id/34');
+    $this->assertXPath('//button[contains(@onclick, "/admin/records/trailer/id/34")]');
+  }
+
+
+  /** @test */
+  public function noticeajaxMediaShouldContainsInitializePopup() {
+    $this->dispatch('/noticeajax/media/id/34');
+    $this->assertXPathContentContains('//script', 'initializePopups();');
+  }
+}
diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php
index a8fa68f82e911820377480d29d2ed2128a32b0bb..0d9d4a08f89fe4ac1d5700ab4c51196c13e36db3 100644
--- a/tests/scenarios/Templates/TemplatesTest.php
+++ b/tests/scenarios/Templates/TemplatesTest.php
@@ -1327,49 +1327,6 @@ class TemplatesRecordMediaDispatchTest extends TemplatesIntonationTestCase {
 
 
 
-class TemplatesDispatchNoticeAjaxTrailerTest extends TemplatesIntonationTestCase {
-
-  public function setUp() {
-    parent::setUp();
-    $this->fixture('Class_Notice',
-                   ['id' => 34,
-                    'titre_principal' => 'Psycho',
-                   ]);
-
-    Class_CosmoVar::set('url_services', 'https://cache-server.org');
-
-    $mock = $this
-      ->mock()
-      ->whenCalled('open_url')
-      ->answers(json_encode(['source' => 'testing',
-                             'player' => '<iframe src="https://www.super-trailers.org/?media=18397590" style="width:500px; height:400px" frameborder="0"></iframe>']));
-
-    Class_WebService_AllServices::setHttpClient($mock);
-  }
-
-
-  /** @test */
-  public function noticeajaxTrailershouldDisplayTrailer() {
-    $this->dispatch('/noticeajax/trailer/id/34/id_profil/72');
-    $this->assertXPath('//div[contains(@class, "embed-responsive")]//iframe[@src= "https://www.super-trailers.org/?media=18397590"][@class="embed-responsive-item"]');
-  }
-
-
-  /** @test */
-  public function noticeajaxMediaDisplayTrailer() {
-    $this->dispatch('/noticeajax/media/id/34/id_profil/72');
-    $this->assertXPath('//div[contains(@class, "embed-responsive")]//iframe[@src= "https://www.super-trailers.org/?media=18397590"][@class="embed-responsive-item"]');
-  }
-
-
-  /** @test */
-  public function shouldRenderEditTrailer() {
-    $this->dispatch('/noticeajax/media/id/34/id_profil/72');
-    $this->assertXPath('//button[contains(@onclick, "/admin/records/trailer/id/34")]');
-  }
-}
-
-
 
 class TemplatesDispatchNoticeAjaxPicturesTest extends TemplatesIntonationTestCase {
 
@@ -2253,32 +2210,6 @@ class TemplateIntonationWithSkinTest extends TemplatesEnabledTestCase {
 
 
 
-class TemplatesNoticeAjaxDigitalResourceTest extends TemplatesIntonationTestCase {
-
-  public function setup() {
-    parent::setup();
-    $this->fixture('Class_Notice', ['id' => 123,
-                                    'type_doc' => Class_TypeDoc::LIVRE_NUM]);
-    $this->fixture('Class_Exemplaire', ['id' => 34,
-                                        'id_origine' => 8,
-                                        'id_notice' => 123]);
-
-    $album = $this->fixture('Class_Album', ['id' => 8,
-                                            'titre' => 'old book',
-                                            'type_doc_id' => Class_TypeDoc::LIVRE_NUM]);
-
-
-    $this->dispatch('noticeajax/digital-resources/id_notice/123/id_profil/72');
-  }
-
-
-  /** @test */
-  public function bookletShouldBeLoadedWithAlbumTypeLivreNumerique() {
-    $this->assertXPathContentContains('//script', '_load_in_scriptsRoot');
-  }
-}
-
-
 
 class TemplatesDispatchIntonationAuthLoginTest extends TemplatesIntonationTestCase {