Answers.Body: <p>You mixed in some code from the documentation resulting in a wrong variable name..</p>
  <pre><code>{% set pdfBlocks = entry.inhaltMatrix.all() %}
      {% if pdfBlocks|length %}
          {% for block in pdfBlocks %}
              {% if block.type == &quot;pdf&quot; %}
                  {% if block.pdfFile %}
                      {% set rel = block.pdfFile.one() %}
                      {% if rel %}
                          &lt;a href=&quot;{{ rel.url }}&quot;&gt;{{ rel.title }}&lt;/a&gt;
                          &lt;img src=&quot;{{ craft.PDFThumb.thumbnail(rel) }}&quot;&gt;
                 
                      {% endif %}
                  {% endif %}
              {% endif %} 
         {% endfor %}
  {% endif %}
  </code></pre>
  <p>Also be sure to go to the plugins settings and set the appropriate assets paths.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-20T19:25:10.983Z
Answers.Text: Thanks, that helps me understand the variable, but it still doesn't work. The plugin creates the `preview` folder for the thumbs, but doesn't create the thumbs. I've double checked paths, permissions, and that ImageMagik is installed, but for whatever reason it won't create the thumbnail. Tried on MAMP and an Arcustech server.
Answers.UserDisplayName: doctorgloom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-21T09:04:08.180Z
Answers.Text: Does it generate an url for the image asset? Also double-check the volumes url and that the volume has public urls enabled.
Answers.UserDisplayName: MisterMike
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-22T18:46:07.197Z
Answers.Text: Yes, it generates the url. Public is enabled (the actual PDF links work fine). I'm stumped. Perhaps the plugin doesn't work well with 3.6.x?
Answers.UserDisplayName: doctorgloom
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-20T00:53:26.417Z
Answers.LastActivityDate: 2021-02-20T00:53:26.417Z
Answers.UserDisplayName: MisterMike
Body: <p>I would like to autogenerate a thumbnail of PDF's, and from <a href="https://craftcms.stackexchange.com/questions/2156/generate-pdf-preview-images-automatically">this question</a> I found the <a href="https://github.com/jmoont/pdfthumb#readme" rel="nofollow noreferrer">plugin PDFThumb</a>. The problem I'm running into is I'm relatively new to Craft, and I can't seem to figure out how to use the provided code when it is with a Matrix field.</p>
  <p>As I said I'm new to this, and I usually end up tying myself in knots when trying to backtrack the variable references, and I think that's the problem here.</p>
  <p>The reference code from the plugin repo:</p>
  <pre><code>{% for myAsset in item.assetRef %}
      &lt;img src=&quot;{{ craft.PDFThumb.thumbnail(myAsset) }}&quot;&gt;
      &lt;img src=&quot;{{ craft.PDFThumb.thumbnail(myAsset, 100, 100) }}&quot;&gt;
      &lt;img src=&quot;{{ craft.PDFThumb.thumbnail(myAsset, 100, 150, true, 'jpg') }}&quot;&gt;
  {% endfor %}
  </code></pre>
  <p>And my code:</p>
  <pre><code>{% set pdfBlocks = entry.infoPagePDF.all() %}
  {% if pdfBlocks|length %}
          {% for block in pdfBlocks %}
              {% if block.type == &quot;pdf&quot; %}
                  {% if block.pdfFile %}
                      {% set rel = block.pdfFile.one() %}
                      {% if rel %}
                          &lt;a href=&quot;{{ rel.url }}&quot;&gt;{{ rel.title }}&lt;/a&gt;
                      {# Autogenerated Thumb #}
                          {% for myAsset in item.assetRef %}
                              &lt;img src=&quot;{{ craft.PDFThumb.thumbnail(myAsset) }}&quot;&gt;
                          {% endfor %}
                      {% endif %}
                  {% endif %}
              {% endif %} 
         {% endfor %}
  {% endif %}
                  
  </code></pre>
  <p>The link generates fine, it's the image that doesn't.</p>
  <p>I've tried a bunch of different variations, but the problem (I think) revolves around the fact I'm not sure what I'm supposed to be referencing in the <code>FOR</code>(myAsset and item.assetRef), so for clarity I reset my attempts to the provided code example.</p>
  
Tags: <matrix><plugins>
Title: Autogenerated PDF Thumbnail using PDFThumb in a Matrix Field
ThreadText: # Autogenerated PDF Thumbnail using PDFThumb in a Matrix Field
  
  (Asked by: username_0 on 2021-02-19)
  
  I would like to autogenerate a thumbnail of PDF's, and from [this question](https://craftcms.stackexchange.com/questions/2156/generate-pdf-preview-images-automatically) I found the [plugin PDFThumb](https://github.com/jmoont/pdfthumb#readme). The problem I'm running into is I'm relatively new to Craft, and I can't seem to figure out how to use the provided code when it is with a Matrix field.
  
  As I said I'm new to this, and I usually end up tying myself in knots when trying to backtrack the variable references, and I think that's the problem here.
  
  The reference code from the plugin repo:
  
  ```
  {% for myAsset in item.assetRef %}
      <img src="{{ craft.PDFThumb.thumbnail(myAsset) }}">
      <img src="{{ craft.PDFThumb.thumbnail(myAsset, 100, 100) }}">
      <img src="{{ craft.PDFThumb.thumbnail(myAsset, 100, 150, true, 'jpg') }}">
  {% endfor %}
  
  ```
  
  And my code:
  
  ```
  {% set pdfBlocks = entry.infoPagePDF.all() %}
  {% if pdfBlocks|length %}
          {% for block in pdfBlocks %}
              {% if block.type == "pdf" %}
                  {% if block.pdfFile %}
                      {% set rel = block.pdfFile.one() %}
                      {% if rel %}
                          <a href="{{ rel.url }}">{{ rel.title }}</a>
                      {# Autogenerated Thumb #}
                          {% for myAsset in item.assetRef %}
                              <img src="{{ craft.PDFThumb.thumbnail(myAsset) }}">
                          {% endfor %}
                      {% endif %}
                  {% endif %}
              {% endif %} 
         {% endfor %}
  {% endif %}
                  
  
  ```
  
  The link generates fine, it's the image that doesn't.
  
  I've tried a bunch of different variations, but the problem (I think) revolves around the fact I'm not sure what I'm supposed to be referencing in the `FOR`(myAsset and item.assetRef), so for clarity I reset my attempts to the provided code example.
  
  **Tags:** matrix, plugins
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-02-20. Score: 2
  
  You mixed in some code from the documentation resulting in a wrong variable name..
  
  ```
  {% set pdfBlocks = entry.inhaltMatrix.all() %}
      {% if pdfBlocks|length %}
          {% for block in pdfBlocks %}
              {% if block.type == "pdf" %}
                  {% if block.pdfFile %}
                      {% set rel = block.pdfFile.one() %}
                      {% if rel %}
                          <a href="{{ rel.url }}">{{ rel.title }}</a>
                          <img src="{{ craft.PDFThumb.thumbnail(rel) }}">
                 
                      {% endif %}
                  {% endif %}
              {% endif %} 
         {% endfor %}
  {% endif %}
  
  ```
  
  Also be sure to go to the plugins settings and set the appropriate assets paths.
  
  > **Comments:**
  > **username_0**: Thanks, that helps me understand the variable, but it still doesn't work. The plugin creates the `preview` folder for the thumbs, but doesn't create the thumbs. I've double checked paths, permissions, and that ImageMagik is installed, but for whatever reason it won't create the thumbnail. Tried on MAMP and an Arcustech server.  
  > **username_1**: Does it generate an url for the image asset? Also double-check the volumes url and that the volume has public urls enabled.  
  > **username_0**: Yes, it generates the url. Public is enabled (the actual PDF links work fine). I'm stumped. Perhaps the plugin doesn't work well with 3.6.x?  
  
  ---
  
  