utpal108
8/30/2018 - 9:30 AM

Laravel SVG Image on Blade

Show SVG Image on blade

<?php
    // Use This
    use DOMDocument;
    //	    For SVG Footer Logo
      view()->composer('partials.footer', function($view) {
          // Instantiate new DOMDocument object
          $svg = new DOMDocument();
          // Load SVG file from public folder
          $svg->load(public_path('images/itclanLogo.svg'));
          // Add CSS class (you can omit this line)
          $svg->documentElement->setAttribute("class", "logo");
          // Get XML without version element
          $logo = $svg->saveXML($svg->documentElement);
          // Attach data to view
          $view->with(['logo'=>$logo]);
      });
      
      // On view page
      {!! $logo !!}