In this paper, we discuss the inflationary magnetogenesis scenario, in which the coupling function is introduced to break the conformal invariance of electromagnetic action. Unlike in conventional models, we deduce the Maxwell’s equations under the perturbed Friedmann–Robertson–Walker metric. We found that the self-consistency of the action depends on the form of the coupling function when the scalar mode perturbations have been considered. Therefore, this self-consistency can be seen as a restriction on the coupling function. In this paper, we give the restrictive equation for coupling function then obtain the specific form of the coupling function in a simple model. We found that the coupling function depends on the potential of the inflaton and thus is model-dependent. We obtain the power spectrum of electric field and magnetic field in large-field inflation model. We also found that the coupling function is an increasing function of time during slow-roll era as most of inflationary magnetogenesis models, it will lead to strong coupling problem. This issue is discussed qualitatively by introducing a correction function during the preheating.