How to show image in table cell in mailer markdown using laravel 5.7?












0















I am using laravel 5.7 and developing a newsletter mailer template in blade where blog posts are shown in table. Please see the code:



Controller to render mailer template in browser:



$posts = [
[
'title' => 'Post with tags',
'slug' => 'post-with-tags',
'excerpt' => "Post's Short description here",
'featured_image' => "1545299956.png",
'campaign_source' => "campaign source",
'campaign_name' => "campaign name",
'campaign_medium' => "campaign medium",
'campaign_term' => "campaign term",
'campaign_content' => "capaign content",
],

[
'title' => 'Post with tags',
'slug' => 'post-with-tags',
'excerpt' => "Post's Short description",
'featured_image' => "1545299956.png",
'campaign_source' => "campaign source",
'campaign_name' => "campaign name",
'campaign_medium' => "campaign medium",
'campaign_term' => "campaign term",
'campaign_content' => "capaign content",
]
];


echo (new AppMailEmailNewsletterForBlogPosts("Mailer Short Description", $posts))->render();


EmailNewsletterForBlogPosts:



$email= $this->subject(config('app.name')." : Our newsletter")->markdown('emails.blog_post_newsletter')->with([
'shortDescription' => $this->shortDescription,
'posts' => $this->posts
]);


blog_post_newsletter.blade.php:



This is working



@component('mail::message')

#{{$shortDescription}}

@component('mail::table')
| Image | Title |
| ------------- |:-------------:|
@foreach($posts as $post)
| ![Test](http://localhost:8000/storage/blog_featured_images/1545299956.png "THIS IS WORKING") | Right-Aligned |
@endforeach
@endcomponent



Thanks,<br>
Exchange Support
@endcomponent


but this is NOT working



@component('mail::message')

#{{$shortDescription}}

@component('mail::table')
| Image | Title |
| ------------- |:-------------:|
@foreach($posts as $post)
@php
$imagePath = asset('storage/blog_featured_images/');
$imagePath.=$post->featured_image;
@endphp
| ![Test]({{$imagePath}} "THIS IS NOT WORKING") | Right-Aligned |
@endforeach
@endcomponent



Thanks,<br>
Exchange Support
@endcomponent


The problem I guess here is whenever I perform any php operations like concatenating an image name with path, It shows me null in browser.
Event I tried passing full image path in $posts array but still featured image is not displayed but browser returns null.



Please help me guide in this scenario.










share|improve this question



























    0















    I am using laravel 5.7 and developing a newsletter mailer template in blade where blog posts are shown in table. Please see the code:



    Controller to render mailer template in browser:



    $posts = [
    [
    'title' => 'Post with tags',
    'slug' => 'post-with-tags',
    'excerpt' => "Post's Short description here",
    'featured_image' => "1545299956.png",
    'campaign_source' => "campaign source",
    'campaign_name' => "campaign name",
    'campaign_medium' => "campaign medium",
    'campaign_term' => "campaign term",
    'campaign_content' => "capaign content",
    ],

    [
    'title' => 'Post with tags',
    'slug' => 'post-with-tags',
    'excerpt' => "Post's Short description",
    'featured_image' => "1545299956.png",
    'campaign_source' => "campaign source",
    'campaign_name' => "campaign name",
    'campaign_medium' => "campaign medium",
    'campaign_term' => "campaign term",
    'campaign_content' => "capaign content",
    ]
    ];


    echo (new AppMailEmailNewsletterForBlogPosts("Mailer Short Description", $posts))->render();


    EmailNewsletterForBlogPosts:



    $email= $this->subject(config('app.name')." : Our newsletter")->markdown('emails.blog_post_newsletter')->with([
    'shortDescription' => $this->shortDescription,
    'posts' => $this->posts
    ]);


    blog_post_newsletter.blade.php:



    This is working



    @component('mail::message')

    #{{$shortDescription}}

    @component('mail::table')
    | Image | Title |
    | ------------- |:-------------:|
    @foreach($posts as $post)
    | ![Test](http://localhost:8000/storage/blog_featured_images/1545299956.png "THIS IS WORKING") | Right-Aligned |
    @endforeach
    @endcomponent



    Thanks,<br>
    Exchange Support
    @endcomponent


    but this is NOT working



    @component('mail::message')

    #{{$shortDescription}}

    @component('mail::table')
    | Image | Title |
    | ------------- |:-------------:|
    @foreach($posts as $post)
    @php
    $imagePath = asset('storage/blog_featured_images/');
    $imagePath.=$post->featured_image;
    @endphp
    | ![Test]({{$imagePath}} "THIS IS NOT WORKING") | Right-Aligned |
    @endforeach
    @endcomponent



    Thanks,<br>
    Exchange Support
    @endcomponent


    The problem I guess here is whenever I perform any php operations like concatenating an image name with path, It shows me null in browser.
    Event I tried passing full image path in $posts array but still featured image is not displayed but browser returns null.



    Please help me guide in this scenario.










    share|improve this question

























      0












      0








      0


      0






      I am using laravel 5.7 and developing a newsletter mailer template in blade where blog posts are shown in table. Please see the code:



      Controller to render mailer template in browser:



      $posts = [
      [
      'title' => 'Post with tags',
      'slug' => 'post-with-tags',
      'excerpt' => "Post's Short description here",
      'featured_image' => "1545299956.png",
      'campaign_source' => "campaign source",
      'campaign_name' => "campaign name",
      'campaign_medium' => "campaign medium",
      'campaign_term' => "campaign term",
      'campaign_content' => "capaign content",
      ],

      [
      'title' => 'Post with tags',
      'slug' => 'post-with-tags',
      'excerpt' => "Post's Short description",
      'featured_image' => "1545299956.png",
      'campaign_source' => "campaign source",
      'campaign_name' => "campaign name",
      'campaign_medium' => "campaign medium",
      'campaign_term' => "campaign term",
      'campaign_content' => "capaign content",
      ]
      ];


      echo (new AppMailEmailNewsletterForBlogPosts("Mailer Short Description", $posts))->render();


      EmailNewsletterForBlogPosts:



      $email= $this->subject(config('app.name')." : Our newsletter")->markdown('emails.blog_post_newsletter')->with([
      'shortDescription' => $this->shortDescription,
      'posts' => $this->posts
      ]);


      blog_post_newsletter.blade.php:



      This is working



      @component('mail::message')

      #{{$shortDescription}}

      @component('mail::table')
      | Image | Title |
      | ------------- |:-------------:|
      @foreach($posts as $post)
      | ![Test](http://localhost:8000/storage/blog_featured_images/1545299956.png "THIS IS WORKING") | Right-Aligned |
      @endforeach
      @endcomponent



      Thanks,<br>
      Exchange Support
      @endcomponent


      but this is NOT working



      @component('mail::message')

      #{{$shortDescription}}

      @component('mail::table')
      | Image | Title |
      | ------------- |:-------------:|
      @foreach($posts as $post)
      @php
      $imagePath = asset('storage/blog_featured_images/');
      $imagePath.=$post->featured_image;
      @endphp
      | ![Test]({{$imagePath}} "THIS IS NOT WORKING") | Right-Aligned |
      @endforeach
      @endcomponent



      Thanks,<br>
      Exchange Support
      @endcomponent


      The problem I guess here is whenever I perform any php operations like concatenating an image name with path, It shows me null in browser.
      Event I tried passing full image path in $posts array but still featured image is not displayed but browser returns null.



      Please help me guide in this scenario.










      share|improve this question














      I am using laravel 5.7 and developing a newsletter mailer template in blade where blog posts are shown in table. Please see the code:



      Controller to render mailer template in browser:



      $posts = [
      [
      'title' => 'Post with tags',
      'slug' => 'post-with-tags',
      'excerpt' => "Post's Short description here",
      'featured_image' => "1545299956.png",
      'campaign_source' => "campaign source",
      'campaign_name' => "campaign name",
      'campaign_medium' => "campaign medium",
      'campaign_term' => "campaign term",
      'campaign_content' => "capaign content",
      ],

      [
      'title' => 'Post with tags',
      'slug' => 'post-with-tags',
      'excerpt' => "Post's Short description",
      'featured_image' => "1545299956.png",
      'campaign_source' => "campaign source",
      'campaign_name' => "campaign name",
      'campaign_medium' => "campaign medium",
      'campaign_term' => "campaign term",
      'campaign_content' => "capaign content",
      ]
      ];


      echo (new AppMailEmailNewsletterForBlogPosts("Mailer Short Description", $posts))->render();


      EmailNewsletterForBlogPosts:



      $email= $this->subject(config('app.name')." : Our newsletter")->markdown('emails.blog_post_newsletter')->with([
      'shortDescription' => $this->shortDescription,
      'posts' => $this->posts
      ]);


      blog_post_newsletter.blade.php:



      This is working



      @component('mail::message')

      #{{$shortDescription}}

      @component('mail::table')
      | Image | Title |
      | ------------- |:-------------:|
      @foreach($posts as $post)
      | ![Test](http://localhost:8000/storage/blog_featured_images/1545299956.png "THIS IS WORKING") | Right-Aligned |
      @endforeach
      @endcomponent



      Thanks,<br>
      Exchange Support
      @endcomponent


      but this is NOT working



      @component('mail::message')

      #{{$shortDescription}}

      @component('mail::table')
      | Image | Title |
      | ------------- |:-------------:|
      @foreach($posts as $post)
      @php
      $imagePath = asset('storage/blog_featured_images/');
      $imagePath.=$post->featured_image;
      @endphp
      | ![Test]({{$imagePath}} "THIS IS NOT WORKING") | Right-Aligned |
      @endforeach
      @endcomponent



      Thanks,<br>
      Exchange Support
      @endcomponent


      The problem I guess here is whenever I perform any php operations like concatenating an image name with path, It shows me null in browser.
      Event I tried passing full image path in $posts array but still featured image is not displayed but browser returns null.



      Please help me guide in this scenario.







      php laravel markdown github-flavored-markdown






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 29 '18 at 5:46









      Dinesh SutharDinesh Suthar

      6510




      6510
























          1 Answer
          1






          active

          oldest

          votes


















          2














          try below:



          $imagePath = $message->embed(asset('storage/blog_featured_images/'.$post->featured_image));





          share|improve this answer
























          • Thanks but what is $message over here ?

            – Dinesh Suthar
            Dec 29 '18 at 5:53











          • @DineshSuthar $message variable used for display image.

            – Jinal Somaiya
            Dec 29 '18 at 5:54











          • @DineshSuthar read laravel.com/docs/5.7/mail#inline-attachments

            – Jinal Somaiya
            Dec 29 '18 at 5:56











          • Nope. I tried this: | ![Test]({{$message->embed(asset('storage/blog_featured_images/'.$post->featured_image))}} "THIS IS NOT WORKING") | Right-Aligned |

            – Dinesh Suthar
            Dec 29 '18 at 6:04













          • @DineshSuthar try without markdown mail.

            – Jinal Somaiya
            Dec 29 '18 at 6:19











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53967038%2fhow-to-show-image-in-table-cell-in-mailer-markdown-using-laravel-5-7%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          try below:



          $imagePath = $message->embed(asset('storage/blog_featured_images/'.$post->featured_image));





          share|improve this answer
























          • Thanks but what is $message over here ?

            – Dinesh Suthar
            Dec 29 '18 at 5:53











          • @DineshSuthar $message variable used for display image.

            – Jinal Somaiya
            Dec 29 '18 at 5:54











          • @DineshSuthar read laravel.com/docs/5.7/mail#inline-attachments

            – Jinal Somaiya
            Dec 29 '18 at 5:56











          • Nope. I tried this: | ![Test]({{$message->embed(asset('storage/blog_featured_images/'.$post->featured_image))}} "THIS IS NOT WORKING") | Right-Aligned |

            – Dinesh Suthar
            Dec 29 '18 at 6:04













          • @DineshSuthar try without markdown mail.

            – Jinal Somaiya
            Dec 29 '18 at 6:19
















          2














          try below:



          $imagePath = $message->embed(asset('storage/blog_featured_images/'.$post->featured_image));





          share|improve this answer
























          • Thanks but what is $message over here ?

            – Dinesh Suthar
            Dec 29 '18 at 5:53











          • @DineshSuthar $message variable used for display image.

            – Jinal Somaiya
            Dec 29 '18 at 5:54











          • @DineshSuthar read laravel.com/docs/5.7/mail#inline-attachments

            – Jinal Somaiya
            Dec 29 '18 at 5:56











          • Nope. I tried this: | ![Test]({{$message->embed(asset('storage/blog_featured_images/'.$post->featured_image))}} "THIS IS NOT WORKING") | Right-Aligned |

            – Dinesh Suthar
            Dec 29 '18 at 6:04













          • @DineshSuthar try without markdown mail.

            – Jinal Somaiya
            Dec 29 '18 at 6:19














          2












          2








          2







          try below:



          $imagePath = $message->embed(asset('storage/blog_featured_images/'.$post->featured_image));





          share|improve this answer













          try below:



          $imagePath = $message->embed(asset('storage/blog_featured_images/'.$post->featured_image));






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 29 '18 at 5:51









          Jinal SomaiyaJinal Somaiya

          693213




          693213













          • Thanks but what is $message over here ?

            – Dinesh Suthar
            Dec 29 '18 at 5:53











          • @DineshSuthar $message variable used for display image.

            – Jinal Somaiya
            Dec 29 '18 at 5:54











          • @DineshSuthar read laravel.com/docs/5.7/mail#inline-attachments

            – Jinal Somaiya
            Dec 29 '18 at 5:56











          • Nope. I tried this: | ![Test]({{$message->embed(asset('storage/blog_featured_images/'.$post->featured_image))}} "THIS IS NOT WORKING") | Right-Aligned |

            – Dinesh Suthar
            Dec 29 '18 at 6:04













          • @DineshSuthar try without markdown mail.

            – Jinal Somaiya
            Dec 29 '18 at 6:19



















          • Thanks but what is $message over here ?

            – Dinesh Suthar
            Dec 29 '18 at 5:53











          • @DineshSuthar $message variable used for display image.

            – Jinal Somaiya
            Dec 29 '18 at 5:54











          • @DineshSuthar read laravel.com/docs/5.7/mail#inline-attachments

            – Jinal Somaiya
            Dec 29 '18 at 5:56











          • Nope. I tried this: | ![Test]({{$message->embed(asset('storage/blog_featured_images/'.$post->featured_image))}} "THIS IS NOT WORKING") | Right-Aligned |

            – Dinesh Suthar
            Dec 29 '18 at 6:04













          • @DineshSuthar try without markdown mail.

            – Jinal Somaiya
            Dec 29 '18 at 6:19

















          Thanks but what is $message over here ?

          – Dinesh Suthar
          Dec 29 '18 at 5:53





          Thanks but what is $message over here ?

          – Dinesh Suthar
          Dec 29 '18 at 5:53













          @DineshSuthar $message variable used for display image.

          – Jinal Somaiya
          Dec 29 '18 at 5:54





          @DineshSuthar $message variable used for display image.

          – Jinal Somaiya
          Dec 29 '18 at 5:54













          @DineshSuthar read laravel.com/docs/5.7/mail#inline-attachments

          – Jinal Somaiya
          Dec 29 '18 at 5:56





          @DineshSuthar read laravel.com/docs/5.7/mail#inline-attachments

          – Jinal Somaiya
          Dec 29 '18 at 5:56













          Nope. I tried this: | ![Test]({{$message->embed(asset('storage/blog_featured_images/'.$post->featured_image))}} "THIS IS NOT WORKING") | Right-Aligned |

          – Dinesh Suthar
          Dec 29 '18 at 6:04







          Nope. I tried this: | ![Test]({{$message->embed(asset('storage/blog_featured_images/'.$post->featured_image))}} "THIS IS NOT WORKING") | Right-Aligned |

          – Dinesh Suthar
          Dec 29 '18 at 6:04















          @DineshSuthar try without markdown mail.

          – Jinal Somaiya
          Dec 29 '18 at 6:19





          @DineshSuthar try without markdown mail.

          – Jinal Somaiya
          Dec 29 '18 at 6:19


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53967038%2fhow-to-show-image-in-table-cell-in-mailer-markdown-using-laravel-5-7%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mossoró

          Error while reading .h5 file using the rhdf5 package in R

          Pushsharp Apns notification error: 'InvalidToken'