Direct photon production in hadronic collisions provides a handle on the gluon PDF by means of the QCD Compton scattering process. In this work we revisit the impact of direct photon production on a global PDF analysis, motivated by the recent availability of the next-to-next-to-leading (NNLO) calculation for this process. We demonstrate that the inclusion of NNLO QCD and leading-logarithmic electroweak corrections leads to a good quantitative agreement with the ATLAS measurements at 8 and 13 TeV, except for the most forward rapidity region in the former case. By including the ATLAS 8 TeV direct photon production data in the NNPDF3.1 NNLO global analysis, we assess its impact on the medium-x gluon. We also study the constraining power of the direct photon production measurements on PDF fits based on different datasets, in particular on the NNPDF3.1 no-LHC and collider-only fits. We also present updated NNLO theoretical predictions for direct photon production at 13 TeV that include the constraints from the 8 TeV measurements.