How to show optimized list of posts with all their attachment images

In page-images.php template I have created this code which displays a list of posts which belong to a category and order them by meta value. So basically it is like a category page, generally nothing special except that each post isn’t shown as a single featured image but with all its images like this: enter image description here This code works but I ask myself how can it be more optimized? Since it has nested WP_Query. Page generates 100 queries and it should be a paginated list like this for each category and for many variations (depending on meta key).

$  query = new WP_Query( array(     'posts_per_page' => 25,      'cat' => 102, // Category ID     'meta_key' => 'rod', // Order by meta field value     'orderby'   => 'meta_value',     'order' => 'ASC',     'post_status' => 'publish',     'meta_query' => array( // Meta value should exists             array(                 'key' => 'rod',                 'value'   => array(''),                 'compare' => 'NOT IN'             )         )     ));  // Inside loop for each post get its images if ($  query->have_posts() ) {     while($  query->have_posts()) {     $  query->the_post();          $  args = array(             'posts_per_page' => -1,              'post_type' => 'attachment',             'post_mime_type' => 'image',             'post_status' => 'any',              'post_parent' => get_the_ID(),             'order' => 'DESC'             );         $  attachments = new WP_Query($  args);             ?>           <div class="col-md-10">             <?php // each loop has a title, meta field and images             <h2><?php echo get_the_title($  key); ?></h2>             <p><?php the_field('latinsko_ime', $  key); ?></p>              <div class="row">                 <?php while($  attachments->have_posts()) : $  attachments->the_post(); ?>                 <div class="col-md-3">                      <a href="<?php the_permalink(); ?>">                         <?php echo wp_get_attachment_image(get_the_ID(), 'category__loop', false, array('class' => 'img-fluid')); ?>                     </a>                  </div>                 <?php endwhile; ?>             </div>          </div>      <?php      }  } 

I have tried removing nested WP_Query and for each loop retrieve images like this $ gallery = get_post_gallery_images( get_the_ID() ); but in this case I have even more queries (127)

Preventing a SharePoint workflow from triggering every time I upload a new list item attachment?

I have a list in SharePoint where users can add requests, assign it to a user, and a workflow runs in the background to notify the user via email when something has been assigned to them.

Unfortunately we’ve had issues with MS Flow recently, so I was forced to build the workflow initially using SharePoint Designer (although I believe the principles should still be the same). So apologies for appearing old fashioned here.

SharePoint is very awkward when it comes to workflows that trigger only when a single field is changed and not the entire list item. Here is a screenshot of what I have in place, essentially it will only send an email if the ‘assigned to’ field has changed to a new person’s name. The workflow triggers every time the list item is modified.

enter image description here

This workflow works pretty well, however, we have a big problem when users are adding attachments to the list item. Every time I add a new attachment, it’s triggering this workflow and sending the email. I’m not really sure why, because the email should only send if the assigned to name has changed, but simply adding an attachment is causing the email to send. It means if users attach 5 documents in a row, the assigned to person receives 5 of the same email.

Does anyone know why this might be happening?

Overriding of the template for the Attachment “thumbnails” in the Media Grid isn’t working

I’m trying to customize the template of the Media Browser (when clicking on “Add Media” button within Edit Post page), by adding a caption with the filename on each thumbnail so I don’t need to select the image to check its filename on the Attachment Details panel.

What I have done so far is a version of the solution described in here: https://stackoverflow.com/a/25948448/8717608

I’m using the “tmpl-attachment” template, from line 506 of media-template.php which is exactly what I need to customize: https://github.com/WordPress/WordPress/blob/master/wp-includes/media-template.php

By clicking the Add Media button I was expecting to see all the thumbs with its filename in a black background on the bottom of the image, but nothing is happening. Looks like I’m missing something and I would appreciate any help to find out what is wrong.

add_action( 'wp_enqueue_media', 'add_media_overrides' ); function add_media_overrides() {     add_action( 'admin_footer-post.php', 'override_media_templates' ); } function override_media_templates(){     ?>      <script type="text/html" id="tmpl-attachment_custom">         <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">             <div class="thumbnail">                 <# if ( data.uploading ) { #>                     <div class="media-progress-bar"><div style="width: {{ data.percent }}%"></div></div>                 <# } else if ( 'image' === data.type && data.sizes ) { #>                     <div class="centered">                         <img src="{{ data.size.url }}" draggable="false" alt=""  style="height: 90%; transform: translate(-50%,-55%);"/>                         <div style="                             transform: translate(-50%,-100%);                             background-color: black;                             color: white;                             margin-top: 50%;                             font-size: 80%;                             z-index: 9999;                             position: relative;                             vertical-align: middle;                         ">{{ data.filename }}</div>                     </div>                 <# } else { #>                     <div class="centered">                         <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #>                             <img src="{{ data.image.src }}" class="thumbnail" draggable="false" alt="" />                         <# } else if ( data.sizes && data.sizes.medium ) { #>                             <img src="{{ data.sizes.medium.url }}" class="thumbnail" draggable="false" alt="" />                         <# } else { #>                             <img src="{{ data.icon }}" class="icon" draggable="false" alt="" />                         <# } #>                     </div>                     <div class="filename">                         <div>{{ data.filename }}</div>                     </div>                 <# } #>             </div>             <# if ( data.buttons.close ) { #>                 <button type="button" class="button-link attachment-close media-modal-icon"><span class="screen-reader-text"><?php _e( 'Remove' ); ?></span></button>             <# } #>         </div>         <# if ( data.buttons.check ) { #>             <button type="button" class="check" tabindex="-1"><span class="media-modal-icon"></span><span class="screen-reader-text"><?php _e( 'Deselect' ); ?></span></button>         <# } #>         <#         var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly';         if ( data.describe ) {             if ( 'image' === data.type ) { #>                 <input type="text" value="{{ data.caption }}" class="describe" data-setting="caption"                     placeholder="<?php esc_attr_e( 'Caption this image&hellip;' ); ?>" {{ maybeReadOnly }} />             <# } else { #>                 <input type="text" value="{{ data.title }}" class="describe" data-setting="title"                     <# if ( 'video' === data.type ) { #>                         placeholder="<?php esc_attr_e( 'Describe this video&hellip;' ); ?>"                     <# } else if ( 'audio' === data.type ) { #>                         placeholder="<?php esc_attr_e( 'Describe this audio file&hellip;' ); ?>"                     <# } else { #>                         placeholder="<?php esc_attr_e( 'Describe this media file&hellip;' ); ?>"                     <# } #> {{ maybeReadOnly }} />             <# }         } #>     </script>     <script>         jQuery(document).ready( function($  ) {             if( typeof wp.media.view.Attachment != 'undefined' ){                 wp.media.view.Attachment.prototype.template = wp.media.template( 'attachment-custom' );             }         });     </script>     <?php } 

Send and HTTP request to Sharepoint with attachment

I’ve created a flow that will send an email to my group whenever there’s a new request from our SharePoint site.

I would like to add/attach an attachment in sending the email from sharepoint list.

I’ve used HTTP request to Sharepoint. Using this:

Site Address: \sharepoint_site\ Method: POST Uri: _api/SP.Utilities.Utility.SendEmail Headers: accept = application/json;odata=nometadata          content-type = application/json;odata=nometadata Body: {         'properties':{        'To':['email@email.com']        'Body': 'Hello world!'        'Subject': 'Request #1'         }       } 

I don’t how to add the attached file from the list. My goal is on every request we will received an email with attachments and the attached file will be automatically delete when the flow is successful.

Any idea on how it will work?.

thanks in advance.

i want all order attachment to print once i “print all” with the invoice in magento sales grid

On the Magento sales grid, there is a dropdown tab that says “Print All”. When I select this, not only do I want the order invoice to print, I also want all the order attachments to print. The order attachments are uploaded using the default Magento custom product functionality as either jpg or pdf files. Please i would be very greatful if you can help me out with the code or solution.

Magento 2 – Email attachment is not working in my controler

Here is my code.

$  pdfFile = 'pub/pdf/13_rajeshnagappan2016@gmail.com.pdf';     $  store = $  this->_storeManager->getStore()->getId();     $  transport = $  this->_transportBuilder->setTemplateIdentifier('enquiry_test_template')         ->setTemplateOptions(['area' => 'frontend', 'store' => $  store])         ->setTemplateVars(             [                 'store' => $  this->_storeManager->getStore(),             ]         )         ->setFrom('general')         ->addTo('rajeshnagappan2016@gmail.com', 'Customer Name');         // ->addAttachment(file_get_contents($  pdfFile));          try {             $  transport = $  this->_transportBuilder->getTransport();             $  transport->sendMessage();             $  this->_inlineTranslation->resume();         } catch (\Exception $  e) {             echo $  e->getMessage(); die;         } 

Flow sending mail attachment with bad encoding

When I send an e-mail attachment with flow, the files get corrupted.

I guess it is sending in wrong encoding.

The original file looks like: enter image description here

The file received in the e-mail looks like: enter image description here

I have tried the “Get file content” and the “Get attachments content” actions, but without luck.

The mail sending: enter image description here

Can anyone help me how to acheive the right encoding or recommend me a better way to send the files?

  1. the filename is with extension .pdf, this is OK

  2. I have tried passing the content trought the binary() function:

binary(body(‘Get_attachment_content’))

but it did not help.

Adding social media icons to email signature apple mail with url, not by attachment

screenshot to end result

I want to add a LinkedIn badge in my email signature.

However, even if I drag-drop from the browser, It is inserted as an attachment, which is personally super annoying.

Is there a way to insert it to be loaded directly from the source from the web? So, as if tag in website.

I tried to copy+paste it from web format. It worked for email content but didn’t work for signature.

Since it was possible for content, it doesn’t seem impossible for mail but can’t find how to do it.