Support » Plugin: Nelio Content - Best Editorial Calendar & Social Media Scheduling » How can I get the featured images to crop from the top?

  • Resolved SeanAUS120

    (@seanaus120)


    Is there a way to get the Nelio featured images to crop from the top, rather than from the center which is the WordPress default?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author David Aguilera

    (@davilera)

    Hi!

    You can try this and let me know if it’s what you want (if it is, we’ll tweak the next version of the plugin so that you can keep using this approach). In public/class-nelio-content-external-featured-image-public.php line 338 you’ll see the following return statement:

    return "style=${quote}background:url( $image_url ) no-repeat center center;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size: cover;${quote}";
    

    Well, right after background-size: cover; add background-position: 50% 0%;. This will tell your browser to center the image horizontally, but align it to the top (which I believe is what you want).

    All the best,
    David

    jess

    (@jess69)

    Hi,

    Was this implemented or should i add the code above? Everyone’s faces are cut off in my images as is.
    Also what will happen on plugin update? i guess make change again?
    Thanks

    • This reply was modified 3 years ago by jess.
    • This reply was modified 3 years ago by jess.
    Plugin Author David Aguilera

    (@davilera)

    Hi @jess69,

    No, I didn’t include that tweak in our plugin. And yes, if you edit the plugin to include that extra CSS property, it’ll be reverted when you updated the plugin. But that approach is the easies solution to test if it fixes the issue as expected or not.

    If it works and want to make it permanent, you can add that rule in your theme’s functions.php file: just print an extra style tag, add a rule to target external featured images (something like img[src*=nc-efi-placeholder]), and include the aforementioned property.

    Regards,
    David

    jess

    (@jess69)

    Thanks, yep it worked. Would it be to much trouble to get the full code so i can just copy and paste in my functions.php file?

    Plugin Author David Aguilera

    (@davilera)

    There you go:

    add_action( 'wp_head', 'nc_tweak_efi_position', 99 );
    function nc_tweak_efi_position() { ?>
    <style>
    img[src*=nc-efi-placeholder] {
      background-position: 50% 0% !important;
    }
    </style>
    <?php
    }//end nc_tweak_efi_position()
    jess

    (@jess69)

    Awesome, thank you so much sir.

    jess

    (@jess69)

    Actually it didn’t work. I put it at the end of my functions.php file. Can you double check the code please? the php opening and close seems off to me but i could be wrong of course 😉

    Plugin Author David Aguilera

    (@davilera)

    The code I shared works, as long as it’s inside the PHP section of your file. Notice that I endthe PHP section right after the header of the function, when I print the style tag, and I reopen it right after the style tag and before I close the function’s body.

    Sam

    (@sam69)

    Oops sorry wrong thread.

    Lol @jess69, checkout our names, i guess you had the same issue as me when the 1s,2s etc etc all all taken, 69 works 😉

    • This reply was modified 3 years ago by Sam. Reason: posted in wrong thread
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How can I get the featured images to crop from the top?’ is closed to new replies.