wordpress,image,wordpress-plugin,resize-crop,wp-image-editor , How to crop image from center using wp_image_editor

How to crop image from center using wp_image_editor


Tag: wordpress,image,wordpress-plugin,resize-crop,wp-image-editor

I am working on WordPress plugin. In plugin the user upload images from meta field and in back end i use wp_image_editor for cropping and re sizing the images. The images re sized very well but on cropping the images not cropped very well. I give x-dimension 100 and y-dimension 0.

$resize_img = wp_get_image_editor( $wpc_prod_img['wpc_resize_img'] );
if ( ! is_wp_error( $resize_img ) ) {
   $resize_img->crop( 100, 0, $wpc_image_width, $wpc_image_height, NULL, NULL, false );

I want to cropped image from center of x-dimension and center of y-dimension. I tried this but its not work

$resize_img->crop( 'center', 'center', $wpc_image_width, $wpc_image_height, NULL, NULL, false );

How can i do this. Is there any solution


Try this code:

$crop = array( 'center', 'center' );
resize( $max_w, $max_h, $crop);


CSS mystery: why the extra height in my div's?

I'm just starting in on a new site and am getting extra space at the top of the div's I'm building for the home page. Using Safari's Web Inspector, I've eliminated any obvious padding or margins being responsible; but it's also seemingly telling me that the height of the div's...

Excel VBA 2013 Print Image

I would like to print an image that shows in a frame on a userform. frame1.Picture = LoadPicture(spath & xPicture & ".jpg") spath is the full path to where the picture is stored. This shows the picture just fine. Now I would like to be able to print it. Is...

Uploading PNG to Website Server

I have seen loads of other topics and I've tried them all. Can someone please help with why this script won't upload PNG files? Blank PNG image being displayed. $image = $_FILES['file']['tmp_name']; $image_name = $_FILES['file']['name']; $ext = pathinfo($image_name, PATHINFO_EXTENSION); $location = "Profiles/{$user}/Picture/{$image_name}"; $new_image = imagecreatetruecolor(100, 100); $source_image = imagecreatefrompng($image); imagealphablending($source_image,...

How to fetch the page id and use it for an image name

I am new in php. I want to make a condition for showing page id and set my image name is pageId and show this background image in my header banner. How to fetch page id use it fetching image for my banner background img. Here is my code: <div...

How to exclude posts without featured images from custom post type WP_Query

We have the following WP_Query which collects all custom posts (except id=191) and lists them randomly: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'post__not_in' => array(191), 'orderby' => 'rand', ); $query_projekte = new WP_Query($args_projekte); How do we extend this to ALSO exclude all posts WITHOUT featured images? Thanks...

Trouble generating Barcode using ZXing library with large data

I need to generate barcode in 128A format with data: 900000588548001100001305000000000207201512345.6|12345.7 I'm using ZXing library and Here is my method: private void barcodeGenerator(String data) { try { com.google.zxing.MultiFormatWriter writer = new MultiFormatWriter(); BitMatrix bm = writer.encode(data, BarcodeFormat.CODE_128, 700, 200); Bitmap ImageBitmap = Bitmap.createBitmap(700, 200, Config.ARGB_8888); for (int i = 0;...

Can not link the author

I am Making a blog site. I want to show all posts of a user by linking with his/her user name. But it's not working. My code is by <a href="<?php get_author_posts_url(get_the_author_meta('ID'));?>"><?php the_author();?></a> What's wrong with it actually?...

Text-decoration/CSS causing text to move

I've tried a bunch of techniques to solve this. I've used float (left/right) and played with positioning (absolute & relative). None worked. Basically my navigation keeps moving when the the text decoration (font-weight: bold; in this case) is applied. I'm new to CSS and this is my first header- so...

Wordpress page can't continue due to this error

I just faced this problem recently, I don't what causes it . But I need help fixing it. The error are : http://www.udesign.my/aaf4/wp-admin/admin-ajax.php?action=woocommerce_checkout Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://fonts.googleapis.com/css?family=century+gothic+:300,400 Failed to load resource: the server responded with a status of...

need wordpress plugin to show 3 type of different kind of text, image and 2 buttons

I have slider image on http://techturners.com/arman-badwal/ page in "featured work" section. I need plugin to create dynamic slider like image in section.I use many sliders like cyclone-slider but they show only title, description and image.

BeautifulSoup: Parsing bad Wordpress HTML

So I need to scrape some a site using Python but the problem is that the markup is random, unstructured, and proving hard to work with. For example <p style='font-size: 24px;'> <strong>Title A</strong> </p> <p> <strong> First Subtitle of Title A </strong> "Text for first subtitle" </p> Then it will...

Woocommece login URL

I have a custom page for login in Wordpress with Woocommerce integrated, and need that when a user click on my-account page, instead of using the login form from woocommerce, redirect to my custom login url. my-account page only must be seen in case the user is logged in,else, I...

ACF Multiple Map Markers

I'm using Advanced Custom Fields and want to pull in the field called 'location' to display some locations on a map. How would i adjust the following code to display multiple markers from my location field? The format of the custom field is like so: echo 'Location: ' . get_field('location');...

Fetch a saved image and display

I am developing an App in which I have stored images through imagePicker. now i want to display same images in my collectionView. I got response as a path path=assets/image/155/155_557b1259b8a51.jpg when i add http://xyz.com.assets/image/155/155_557b1259b8a51.jpg then it shows error. How can i get the images through this path.Please Help me out....

How to crop image from center using wp_image_editor

I am working on WordPress plugin. In plugin the user upload images from meta field and in back end i use wp_image_editor for cropping and re sizing the images. The images re sized very well but on cropping the images not cropped very well. I give x-dimension 100 and y-dimension...

WooCommerce seems to only orderby date and not price

I am loading in variable products via a custom WP_Query $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'beast-balls', 'orderby' => 'date', 'order' => 'desc' ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="product-node cat-beast-balls">...

Run AJAX function on form submit button after javascript confirm() cancel

I have a form where and AJAX function runs on form submission to make sure that the data in the form doesn't conflict with data in the database. If a conflict is found, the AJAX function pops up a confirm() box. If the user clicks "OK", the form is submitted....

CSS disable horizontaly scrolling - Wordpress [on hold]

Hi im working on a wordpress blog and have the following problem: http://www.catlovers.co/17-cat-reactions-that-sum-up-your-love-life/ If i resize the browser (X-Axies) to a minimum like surfing on a mobile device i am able to scroll to the right in the Contend section (hold down middle mouse button). How can i change my...

Dynamically resize side-by-side images with different dimensions to the same height

I have two images side-by-side within a block-level container with arbitrarily different dimensions (as in, they could be any two images) that I want to dynamically adjust the width of so that the overall height of the two images is the same. I don't think this can be done in...

woocommerce - make order notes required

is it posible to make woo 'order_comments' field required - and show message If the field is not filled I have tried the following code but I can not get it to work. add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process'); function my_custom_checkout_field_process() { // Check if set, if its not set add an error. if...

Loading images into html5 canvas

I am using nodejs sails for my app. The app is going to use 50-100 images at some points. I was wondering if someone can point pro and cons of using /assests/images/ folder vs outside repository i.e. AWS S3 for image storing and pulling to draw on the canvas.

Saving images with more than 8 bits per pixel in matlab

I need to save a set of pre-processing images in matlab, resulting in grayscale images. The problem is the fact that these pre-processed images have pixel values higher than 255. If I save them with imwrite() as, for instance, .PNG files, does matlab normalize the values to be in [0,255]...

Excluding certain pages from being redirected to https

I'm using the following rules on my WordPress website to: Redirect all http pages to https Redirect the careers page to http <IfModule mod_rewrite.c> RewriteEngine On # Go to https if not on careers RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/careers$ [NC] RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L] # Go to http if...

Preload image for seamless background image change in JavaScript

I have a Python websocket application which sends an image path to a JavaScript HTML file. When the image path is received, I change the background image of the webpage to the supplied image. The issue I'm having at the moment, is when the background changes from the old image...

Create mask from bwtraceboundary in Matlab

I'm trying to create a mask (or similar result) in order to erase pieces of a binary image that are not attached to the object surrounded by the boundary. I saw this thread (http://www.mathworks.com/matlabcentral/answers/120579-converting-boundary-to-mask) to do this from bwboundaries, but I'm having trouble making suitable changes to it. My goal...

WordPress expanding grid with thumbnail

I'm using codrops solution to display team members in an expanding grid: http://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/ I was already able to change some code to display my post thumbnail in the grid preview. However, I want to display the same picture in full size in the expanded view. In the original version it...

Wordpress function to effect only one (custom) post type, and not every post

I'm having an issue with a custom post type (WP Job Manager). I am using the following code in my functions file to 'add a default image to posts that have no image attached'. function custom_default_cover_image( $image, $args ) { global $post; if ( $image ) { return $image; }...

Change Background image in WPF using C# [duplicate]

This question already has an answer here: Change WPF window background image in C# code 3 answers I'd like to change the background image of my WPF application by a button. I know how to do it using WindowsForms, but in WPF I failed. I found a solution already,...

Wordpress End If Statements

Apologies, PHP is not my strongest area so this might seem super easy to others. I am trying to implement a statement to say, when there is something in my WooCommerce Cart to show the cart. If there's nothing in the cart then show nothing. The code I have so...

How to call posts from PHP

I have a website, that uses WP Super Cache plugin. I need to recycle cache once a day and then I need to call 5 posts (URL adresses) so WP Super Cache put these posts into cache again (caching is quite time consuming so I'd like to have it precached...

Foundation and Wordpress blank spaces

Anyone has an idea about the blank spaces that I'm getting in a while loop with wordpress using foundation framework? <div class="large-8 columns"> <?php query_posts(array('category_name' => 'revista', 'paged' => get_query_var('paged'), 'posts_per_page' => 9 )); ?> <?php while ( have_posts() ) : the_post(); ?> <article class="boletin large-4 columns" style="min-height:1px;"> <a href="<?php...

Wordpress log out using URL and redirect to specify page

I have one Wordpress installation . i need to log out the user without any indication user is coming from particular URL.Is it possible? My code: <?php if($_GET['logout'] == 1) { $redirect_to = current_page_url(); ?> <script> window.location.href="<?php echo wp_logout_url( $redirect_to ); ?>"; </script> <?php } ?> I am using above...

Wordpress Custom Post Type categroies

I have a custom post type called STORIES. When a user adds a new STORY, I need them to be able to assign a category (or multiple categories) to the post so I can sort them later by category. To do this, I only want specific categories I assign to...

Changing font-size of
  • on wordpress

  • css,wordpress,html-lists
    I am adding some pages on a wordpress themed website. There is a table with 3 columns: 1st column will be the title (larger font). Since it looks better and editing is easier, I started using <ul> instead of <td> Even though it works fine on JSFIDDLE font-size on the...

    Coding after Wordpress loop not showing

    I have been working on a custom archive page but I have run into some trouble. The pagination is shifting down into the footer area. I have gone through my code several times and I cannot work out why this is happening. If I remove the loop, the template works...

    How to prevent exceeding matrix dimensions while dividing an image into blocks?

    I have an image which I want to divide into overlapping blocks. I have set the box to be of size 8 rows and 8 columns, and the overlapping factor to be 4 rows/columns. This is what I have written to solve this: img = imread('a03-017-05.png'); overlap = 4 count...

    Two language site in wordpress what i can do [on hold]

    I want to create 2 language site in word press. I am pretty new in word press. so what can i do. I will have 2 different theme for each language or do something else. The English is for left to right while Arabic is for right to left. So...

    login with username or email in wordpress

    I am working on login template...but I want to make login with username as well as email.I got code with for that but it is not worked,it is as follow: function login_with_email_address($username) { $user = get_user_by('email',$username); if(!empty($user->user_login)) $username = $user->user_login; return $username; } add_action('wp_authenticate','login_with_email_address',10,1); I already put action in 'authenticate'...

    Add second single product page in Woocommerce

    Is it possible to add a second single product page in Woocommerce? So basically when I am at the single product page I click the "next" button and I get directed to the same single product page with another template. So I just want to retrieve the same data on...

    How to search images by name inside a folder?

    I have a MySQL table with a column "rounds" and each "rounds" has his own photos. Exemple round1 has photos from start=380 end=385. This means it has 6 photos and the name of the photos contains 380,381,382,383,384 or 385 inside. I use this PHP code to display the photos from...

    wp_schedule_event hook sheduled but not working

    I'm trying to trigger cron job from WordPress Plugin that I'm writing (It's gonna take all new Products and export them to CSV every day) so the problem is that when I'm put this code in functions.php all working great and the code is valid but from the plugin folder...

    Images not loaded from master page in directory

    I will make a website whit ASP.NET using C# on the background. I have make my master page with the following image: <img src="afbeeldingen/berichten.png" alt="new messages" /> Because I have a lot of pages in my site, I have make directories in my solution. My problem is now when I...

    Bxslider, Custom Fields & Wordpress

    Good Afternoon, can anyone explain how i can achieve two things with the existing code below: Remove the null values, as these are exporting bxslider items that have broken links For some reason two versions of each image in the the pager are showing. Can anyone see why and how...

    How to make a Javafx Image Crop App

    I am building an application for my colleagues to crop image. I use FXML with Scene Builder to build the GUI. The user click a button to choose a image from his computer. Then, the image is shown in the GUI. User can zoom and move in the pane. At...

    Python Resize Multiple images ask user to continue

    I'm trying to make a script that resize multiple or a single image based on a data pulled from XML. My question is if i have multiple images how can I print out a qusetion like "There are more than 1 image do you wish to resize image 2 also?......

    WooCommerce: How to display Category Name in single-product.php

    How can I display the category name in single-product.php? In archive-product.php the code is: <?php woocommerce_page_title(); ?> but what could I use to show the category name in the single-product.php that belong to the category?...

    Creating complex queries with WP_Query in Wordpress

    Here's a complex query which we've built using WP_Query. It should: Ignore post id 191 AND Select all posts with 'reihenfolge' <= 18 AND Ignore posts without a featured image AND Order them randomly Here is the code: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'meta_query' => array('relation'...

    adding link_to with image_tag and image path both

    I am trying to replace the tag with link_to in my rails application view. for replacing I have svg icon, text and link all in one tag. Here is below <a class="navbar-brand" href="index.html"><%= image_tag 'logo.svg', "data-svg-fallback" => image_path('logo.svg'), :align=> "left" ,:style => "padding-right: 5px;" %> My Project </a> but I...

    Crop does not work for gallery images

    I am using the following code to crop images from camera and gallery : private void doCrop() { final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>(); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, 0); int size = list.size(); if (size == 0) { Toast.makeText(this, getApplicationContext().getString(R.string.crop_unavailable), Toast.LENGTH_SHORT).show(); // return }...