Monthly Archive: November 2019

Laravel does not load asset via HTTPS

Problem: After turn on HTTPS, Laravel load the assets via HTTP and it cause Google Chrome inspector to pop up a message “…was loaded over HTTPS, but requested an insecure…

Although you access the page via HTTPS but HTTPS page is asked to load a resource over HTTP. In general, simply change the setting in order to load assets via HTTPS.

Solution: for Laravel check out this post, below changes work for me.

Find AppServiceProvider.php and change boot()

    public function boot()
    {
        //
        If (env('APP_ENV') != 'local') {
            $this->app['request']->server->set('HTTPS', true);
        }

    }

If you are just for testing (local environment), simply change APP_ENV checking:

If (env('APP_ENV') == 'local') {

Laravel composer update failed with carbon extension

Problem: Run composer update failed with a message “providing support and update for 1.x versions, please upgrade to Carbon 2.”

This is because of carbon version 1 is deprecated, you have to use Carbon 2, but Carbon requires Laravel 5.8

Solution: According to the official Carbon website, you can just update composer.json with below content:

{
    "require": {
        "nesbot/carbon": "2.25.0 as 1.39.0"
        "kylekatarnls/laravel-carbon-2": "^1.0.0"
    }
}

In this case, you can still be using other versions of Laravel

WordPress image in poor quality/ image being resized

Problem: Upload some images with high quality, somehow showing a poor quality or showing a resized image URL at the end.

There are a few possible things causing this like third party plugin and auto-cropping images function.

Solution: First if you installed some optimize tools like Jetpack please disable it or turn off Image Accelerator.

According to this post, add below code into functions.php located in the themes folder that you are using.

add_filter( 'post_thumbnail_html', 'remove_wps_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_wps_width_attribute', 10 );
  
function remove_wps_width_attribute( $html ) {
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    return $html;
}

or according to this, add below code to remove size attribute

add_filter( 'wp_calculate_image_srcset_meta', '__return_null' );
Secured By miniOrange