How to add fetchpriority to first 2 images in wordpress?

you can use this filter to add attributes too.

e.g. like that with you own counter :

add_filter("wp_get_loading_optimization_attributes", function ($loading_attrs, $tag_name, $attr, $context) {
    
    if (!isset($GLOBALS["MY_PLUGIN"]["fetchpriority_count"])) {
        $GLOBALS["MY_PLUGIN"]["fetchpriority_count"] = 0;
    }
    
    if ($GLOBALS["MY_PLUGIN"]["fetchpriority_count"] < 5) {
        $GLOBALS["MY_PLUGIN"]["fetchpriority_count"]++;
        $loading_attrs["fetchpriority"] = "high";
    }
    
    
    return $loading_attrs;
    
}, 10, 4);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)